simple-squiggle

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

matrix.md (1736B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function matrix
      4 
      5 Create a Matrix. The function creates a new `math.Matrix` object from
      6 an `Array`. A Matrix has utility functions to manipulate the data in the
      7 matrix, like getting the size and getting or setting values in the matrix.
      8 Supported storage formats are 'dense' and 'sparse'.
      9 
     10 
     11 ## Syntax
     12 
     13 ```js
     14 math.matrix()                         // creates an empty matrix using default storage format (dense).
     15 math.matrix(data)                     // creates a matrix with initial data using default storage format (dense).
     16 math.matrix('dense')                  // creates an empty matrix using the given storage format.
     17 math.matrix(data, 'dense')            // creates a matrix with initial data using the given storage format.
     18 math.matrix(data, 'sparse')           // creates a sparse matrix with initial data.
     19 math.matrix(data, 'sparse', 'number') // creates a sparse matrix with initial data, number data type.
     20 ```
     21 
     22 ### Parameters
     23 
     24 Parameter | Type | Description
     25 --------- | ---- | -----------
     26 `data` | Array &#124; Matrix | A multi dimensional array
     27 `format` | string | The Matrix storage format
     28 
     29 ### Returns
     30 
     31 Type | Description
     32 ---- | -----------
     33 Matrix | The created matrix
     34 
     35 
     36 ## Examples
     37 
     38 ```js
     39 let m = math.matrix([[1, 2], [3, 4]])
     40 m.size()                        // Array [2, 2]
     41 m.resize([3, 2], 5)
     42 m.valueOf()                     // Array [[1, 2], [3, 4], [5, 5]]
     43 m.get([1, 0])                    // number 3
     44 ```
     45 
     46 
     47 ## See also
     48 
     49 [bignumber](bignumber.md),
     50 [boolean](boolean.md),
     51 [complex](complex.md),
     52 [index](index.md),
     53 [number](number.md),
     54 [string](string.md),
     55 [unit](unit.md),
     56 [sparse](sparse.md)