linear-algebra.md (4023B)
1 ## Linear Algebra 2 3 ## Instance Functionality 4 5 ### add( arg ) 6 7 Adds value to all entries. 8 9 jStat([[1,2,3]]).add( 2 ) === [[3,4,5]]; 10 11 ### subtract( arg ) 12 13 Subtracts all entries by value. 14 15 jStat([[4,5,6]]).subtract( 2 ) === [[2,3,4]]; 16 17 ### divide( arg ) 18 19 Divides all entries by value. 20 21 jStat([[2,4,6]]).divide( 2 ) === [[1,2,3]]; 22 23 ### multiply( arg ) 24 25 Multiplies all entries by value. 26 27 jStat([[1,2,3]]).multiply( 2 ) === [[2,4,6]]; 28 29 ### dot( arg ) 30 31 Takes dot product. 32 33 ### pow( arg ) 34 35 Raises all entries by value. 36 37 jStat([[1,2,3]]).pow( 2 ) === [[1,4,9]]; 38 39 ### exp() 40 41 Exponentiates all entries. 42 43 jStat([[0,1]]).exp() === [[1, 2.718281828459045]] 44 45 ### log() 46 47 Returns the natural logarithm of all entries. 48 49 jStat([[1, 2.718281828459045]]).log() === [[0,1]]; 50 51 ### abs() 52 53 Returns the absolute values of all entries. 54 55 jStat([[1,-2,-3]]).abs() === [[1,2,3]]; 56 57 ### norm() 58 59 Computes the norm of a vector. Note that if a matrix is passed, then the 60 first row of the matrix will be used as a vector for `norm()`. 61 62 ### angle( arg ) 63 64 Computes the angle between two vectors. Note that if a matrix is passed, then 65 the first row of the matrix will be used as the vector for `angle()`. 66 67 ## Static Functionality 68 69 ### add( arr, arg ) 70 71 Adds `arg` to all entries of `arr` array. 72 73 ### subtract( arr, arg ) 74 75 Subtracts all entries of the `arr` array by `arg`. 76 77 ### divide( arr, arg ) 78 79 Divides all entries of the `arr` array by `arg`. 80 81 ### multiply( arr, arg ) 82 83 Multiplies all entries of the `arr` array by `arg`. 84 85 ### dot( arr1, arr2 ) 86 87 Takes the dot product of the `arr1` and `arr2` arrays. 88 89 ### outer( A, B ) 90 91 Takes the outer product of the `A` and `B` arrays. 92 93 outer([1,2,3],[4,5,6]) === [[4,5,6],[8,10,12],[12,15,18]] 94 95 ### pow( arr, arg ) 96 97 Raises all entries of the `arr` array to the power of `arg`. 98 99 ### exp( arr ) 100 101 Exponentiates all entries in the `arr` array. 102 103 ### log( arr ) 104 105 Returns the natural logarithm of all entries in the `arr` array 106 107 ### abs( arr ) 108 109 Returns the absolute values of all entries in the `arr` array 110 111 ### norm( arr ) 112 113 Computes the norm of the `arr` vector. 114 115 ### angle( arr1, arr2 ) 116 117 Computes the angle between the `arr1` and `arr2` vectors. 118 119 ### aug( A, B ) 120 121 Augments matrix `A` by matrix `B`. Note that this method returns a plain matrix, 122 not a jStat object. 123 124 ### det( A ) 125 126 Calculates the determinant of matrix `A`. 127 128 ### inv( A ) 129 130 Returns the inverse of the matrix `A`. 131 132 ### gauss_elimination( A, B ) 133 134 Performs Gaussian Elimination on matrix `A` augmented by matrix `B`. 135 136 ### gauss_jordan( A, B ) 137 138 Performs Gauss-Jordan Elimination on matrix `A` augmented by matrix `B`. 139 140 ### lu( A ) 141 142 Perform the LU decomposition on matrix `A`. 143 144 `A` -> `[L,U]` 145 146 st. 147 148 `A = LU` 149 150 `L` is lower triangular matrix. 151 152 `U` is upper triangular matrix. 153 154 ### cholesky( A ) 155 156 Performs the Cholesky decomposition on matrix `A`. 157 158 `A` -> `T` 159 160 st. 161 162 `A = TT'` 163 164 `T` is lower triangular matrix. 165 166 ### gauss_jacobi( A, b, x, r ) 167 168 Solves the linear system `Ax = b` using the Gauss-Jacobi method with an initial guess of `r`. 169 170 ### gauss_seidel( A, b, x, r ) 171 172 Solves the linear system `Ax = b` using the Gauss-Seidel method with an initial guess of `r`. 173 174 ### SOR( A, b, x, r, w ) 175 176 Solves the linear system `Ax = b` using the sucessive over-relaxation method with an initial guess of `r` and parameter `w` (omega). 177 178 ### householder( A ) 179 180 Performs the householder transformation on the matrix `A`. 181 182 ### QR( A ) 183 184 Performs the Cholesky decomposition on matrix `A`. 185 186 `A` -> `[Q,R]` 187 188 `Q` is the orthogonal matrix. 189 190 `R` is the upper triangular. 191 192 ### lstsq( A, b ) 193 194 Solves least squard problem for Ax=b as QR decomposition way. 195 196 If `b` is of the `[[b1], [b2], [b3]]` form, the method will return an array of the `[[x1], [x2], [x3]]` form solution. 197 198 Otherwise, if `b` is of the `[b1, b2, b3]` form, the method will return an array of the `[x1,x2,x3]` form solution. 199 200 201 202 203 ### jacobi() 204 205 ### rungekutta() 206 207 ### romberg() 208 209 ### richardson() 210 211 ### simpson() 212 213 ### hermite() 214 215 ### lagrange() 216 217 ### cubic_spline() 218 219 ### gauss_quadrature() 220 221 ### PCA()