diff options
Diffstat (limited to 'packages/base/src/Data')
-rw-r--r-- | packages/base/src/Data/Packed/Numeric.hs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs index 7aa53f1..6027f43 100644 --- a/packages/base/src/Data/Packed/Numeric.hs +++ b/packages/base/src/Data/Packed/Numeric.hs | |||
@@ -160,7 +160,29 @@ instance Mul Vector Matrix Vector where | |||
160 | 160 | ||
161 | -------------------------------------------------------------------------------- | 161 | -------------------------------------------------------------------------------- |
162 | 162 | ||
163 | -- | least squares solution of a linear system, similar to the \\ operator of Matlab\/Octave (based on linearSolveSVD) | 163 | {- | Least squares solution of a linear system, similar to the \\ operator of Matlab\/Octave (based on linearSolveSVD) |
164 | |||
165 | @ | ||
166 | a = (3><2) | ||
167 | [ 1.0, 2.0 | ||
168 | , 2.0, 4.0 | ||
169 | , 2.0, -1.0 ] | ||
170 | @ | ||
171 | |||
172 | @ | ||
173 | v = vector [13.0,27.0,1.0] | ||
174 | @ | ||
175 | |||
176 | >>> let x = a <\> v | ||
177 | >>> x | ||
178 | fromList [3.0799999999999996,5.159999999999999] | ||
179 | |||
180 | >>> a #> x | ||
181 | fromList [13.399999999999999,26.799999999999997,1.0] | ||
182 | |||
183 | It also admits multiple right-hand sides stored as columns in a matrix. | ||
184 | |||
185 | -} | ||
164 | infixl 7 <\> | 186 | infixl 7 <\> |
165 | (<\>) :: (LSDiv c, Field t) => Matrix t -> c t -> c t | 187 | (<\>) :: (LSDiv c, Field t) => Matrix t -> c t -> c t |
166 | (<\>) = linSolve | 188 | (<\>) = linSolve |