simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

ones.md (1216B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function ones
      4 
      5 Create a matrix filled with ones. The created matrix can have one or
      6 multiple dimensions.
      7 
      8 
      9 ## Syntax
     10 
     11 ```js
     12 math.ones(m)
     13 math.ones(m, format)
     14 math.ones(m, n)
     15 math.ones(m, n, format)
     16 math.ones([m, n])
     17 math.ones([m, n], format)
     18 math.ones([m, n, p, ...])
     19 math.ones([m, n, p, ...], format)
     20 ```
     21 
     22 ### Parameters
     23 
     24 Parameter | Type | Description
     25 --------- | ---- | -----------
     26 `size` | ...number &#124; Array | The size of each dimension of the matrix
     27 `format` | string | The Matrix storage format
     28 
     29 ### Returns
     30 
     31 Type | Description
     32 ---- | -----------
     33 Array &#124; Matrix &#124; number | A matrix filled with ones
     34 
     35 
     36 ### Throws
     37 
     38 Type | Description
     39 ---- | -----------
     40 
     41 
     42 ## Examples
     43 
     44 ```js
     45 math.ones(3)                   // returns [1, 1, 1]
     46 math.ones(3, 2)                // returns [[1, 1], [1, 1], [1, 1]]
     47 math.ones(3, 2, 'dense')       // returns Dense Matrix [[1, 1], [1, 1], [1, 1]]
     48 
     49 const A = [[1, 2, 3], [4, 5, 6]]
     50 math.ones(math.size(A))       // returns [[1, 1, 1], [1, 1, 1]]
     51 ```
     52 
     53 
     54 ## See also
     55 
     56 [zeros](zeros.md),
     57 [identity](identity.md),
     58 [size](size.md),
     59 [range](range.md)