@@ -251,22 +251,18 @@ instead of the longer form
251
251
252
252
## Creation & transformation
253
253
254
- When the resulting element type cannot be inferred, functions that
255
- create and transform arrays are provided in pairs; one of these will
256
- allow you to specify the array-element-type of the result, while the
257
- other assumes it is ` t ` . The former ends with a ` * ` , and the
258
- ` element-type ` is always its first argument. Examples are given for
259
- the versions without ` * ` ; use the other when you are optimizing your
260
- code and you are sure you can constrain to a given element-type.
254
+ Use the functions in this section to create commonly used arrays
255
+ types. When the resulting element type cannot be inferred from an
256
+ existing array or vector, you can pass the element type as an optional
257
+ argument. The default is elements of type ` T ` .
261
258
262
259
* Element traversal order of these functions is unspecified* . The
263
260
reason for this is that the library may use parallel code in the
264
261
future, so it is unsafe to rely on a particular element traversal
265
262
order.
266
263
267
264
The following functions all make a new array, taking the dimensions as
268
- input. The version ending in ` * ` also takes the array type as first
269
- argument. There are also versions ending in ` ! ` which do not make a
265
+ input. There are also versions ending in ` ! ` which do not make a
270
266
new array, but take an array as first argument, which is modified and
271
267
returned.
272
268
@@ -280,16 +276,23 @@ returned.
280
276
281
277
For example:
282
278
``` lisp
279
+ (aops:zeros 3)
280
+ ; => #(0 0 0)
281
+
282
+ (aops:zeros 3 'double-float)
283
+ ; => #(0.0d0 0.0d0 0.0d0)
284
+
283
285
(aops:rand '(2 2))
284
286
; => #2A((0.6686077 0.59425664)
285
287
; (0.7987722 0.6930506))
286
288
287
- (aops:rand* 'single-float ' (2 2))
289
+ (aops:rand ' (2 2) 'single-float )
288
290
; => #2A((0.39332366 0.5557821)
289
291
; (0.48831415 0.10924244))
290
292
291
293
(let ((a (make-array '(2 2) :element-type 'double-float)))
292
294
;; Modify array A, filling with random numbers
295
+ ;; element type is taken from existing array
293
296
(aops:rand! a))
294
297
; => #2A((0.6324615478515625d0 0.4636608362197876d0)
295
298
; (0.4145939350128174d0 0.5124958753585815d0))
@@ -298,6 +301,7 @@ For example:
298
301
``` lisp
299
302
(linspace 0 4 5) ;=> #(0 1 2 3 4)
300
303
(linspace 1 3 5) ;=> #(0 1/2 1 3/2 2)
304
+ (linspace 1 3 5 'double-float) ;=> #(1.0d0 1.5d0 2.0d0 2.5d0 3.0d0)
301
305
(linspace 0 4d0 3) ;=> #(0.0d0 2.0d0 4.0d0)
302
306
```
303
307
0 commit comments