![]() There are two methods available on matrices that allow to get or set a single index ( 1, 2 ), 5 ) // Matrix,, ] Getting and setting a value in a matrix # The subset will be applied to the matrix itself c. index ( 2, ), ) // Array,, , ] // replace a subset. The subset will be applied to a clone of the matrix math. index ( 1, 2 )) // 5 // replace a subset. index (, 0 )) // Matrix,, ] // get a subset d. create some matrices const a = const b =, ] const c = math. Note that mathematical applications like Matlab and Octave work differently, Matrix indexes in math.js are zero-based, like most programming languages Or a set of values for each dimension of a matrix. In the matrix, and if not, a subset of the matrix will be returned.Ī subset can be defined using an Index. When parameter replacement is provided, the function will replace a subset The static function subset(matrix, index ) can be used. Matrices have a subset function, which is applied to the matrix itself: Subsets of a matrix can be retrieved or replaced using the function subset. index ( 1, 0 )) // 2 Getting or replacing subsets # squeeze (]) // 3 // subsets are automatically squeezed const b = math. ![]() Normally rendered as the column, and the second dimension is rendered as When creating and printing a two dimensional matrix, the first dimension is Note that the dimensions themselves do not have a meaning attached. size () // Array, // get the size of a multi-dimensional matrix const c =, ],, ]] math. size ( b ) // Matrix, // matrices have a function size (always returns an Array) b. size ( ' hello world ' ) // Matrix, // get the size of a two-dimensional matrix const a = ] // Array const b = math. unit ( ' 5.3 mm ' )) // Matrix, // get the size of a one-dimensional matrix (a vector) and a string math. Returns a Matrix or Array, depending on the configuration option matrix.įurthermore, matrices have a function size as well, which always returns The size of a matrix can be calculated with the function size. add ( c, 2 ) // Array,, ] // calculate the determinant of a matrix math. multiply ( c, d ) // Matrix,, ] // add a number to a matrix math. ![]() ![]() factorial ( b ) // Array, // multiply an array with a matrix const c =, ] // Array const d = math. sqrt ( a ) // Matrix, // perform a calculation on an array const b = math. perform a calculation on a matrix const a = math. Note that in case of numbers as arguments, the output isĭetermined by the option matrix as discussed in section When the input is a Matrix, the output willīe a Matrix. Or matrix containing the dimensions for the matrix. The functions ones, zeros, and identity also accept a single array identity ( 3 ) // Matrix, size, ,, ] math. ones ( 2, 2 ), 5 ) // Matrix, size, , ] // identity creates an identity matrix math. zeros ( 2, 2, 2 ) // Matrix, size, //, ],, ]] // ones creates a matrix filled with ones math. zeros ( 3, 2 ) // Matrix, size, ,, ] math. zeros creates a matrix filled with zeros math. Which can be a string 'Matrix' (default) or 'Array'. Input, the output is determined by the configuration option matrix, In case of mixed input, a Matrix is returned.įor functions where the type of output cannot be determined from the In most cases, the type of matrix output from functions is determined by theįunction input: An Array as input will return an Array, a Matrix as input Matrix manipulation such as subset, size, resize, clone, and more. A Matrix is an object wrappedĪround a regular JavaScript Array, providing utility functions for easy
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |