|
321 | 321 | (error "Can't compute cholesky on an array of dimensionality " dims)))) AMatrix
|
322 | 322 | AMatrix
|
323 | 323 | (cholesky [m options]
|
324 |
| - (let |
325 |
| - [result (Cholesky/decompose m)] |
326 |
| - (if result |
327 |
| - (with-keys {:L (.getL result) :L* (.getU result)} (:return options)) |
328 |
| - nil)))) |
| 324 | + (when-let [result (Cholesky/decompose m)] |
| 325 | + (with-keys {:L (.getL result) :L* (.getU result)} (:return options))))) |
329 | 326 |
|
330 | 327 | (extend-protocol mp/PSVDDecomposition
|
331 | 328 | INDArray
|
332 |
| - (cholesky [m options] |
| 329 | + (svd [m options] |
333 | 330 | (let [dims (dimensionality m)]
|
334 | 331 | (if (== 2 dims)
|
335 | 332 | (mp/svd (Matrixx/toMatrix m) options)
|
336 | 333 | (error "Can't compute SVD on an array of dimensionality " dims)))) AMatrix
|
337 | 334 | AMatrix
|
338 | 335 | (svd [m options]
|
339 |
| - (let |
340 |
| - [result (SVD/decompose m)] |
341 |
| - (if result |
342 |
| - (with-keys {:U (.getU result) :S (diagonal (.getS result)) :V* (.getTranspose (.getV result))} (:return options)) |
343 |
| - nil)))) |
| 336 | + (when-let [result (SVD/decompose m)] |
| 337 | + (with-keys {:U (.getU result) :S (diagonal (.getS result)) :V* (.getTranspose (.getV result))} (:return options))))) |
| 338 | + |
| 339 | +;; TODO: complete Eigendecomposition |
| 340 | +;; Need to handle complex numbers! |
| 341 | +; |
| 342 | +;(extend-protocol mp/PEigenDecomposition |
| 343 | +; INDArray |
| 344 | +; (eigen [m options] |
| 345 | +; (let [dims (dimensionality m)] |
| 346 | +; (if (== 2 dims) |
| 347 | +; (mp/eigen (Matrixx/toMatrix m) options) |
| 348 | +; (error "Can't compute Eigendecomposition on an array of dimensionality " dims)))) AMatrix |
| 349 | +; AMatrix |
| 350 | +; (eigen [m options] |
| 351 | +; (when-let [result (Eigen/decompose m)] |
| 352 | +; (let [eigenvalues (.getEigenvalues result) |
| 353 | +; eigenvectors (.getEigenVectors result) |
| 354 | +; Qt (VectorMatrixMN/wrap eigenvectors)] |
| 355 | +; (with-keys {:Q (.transpose Qt) |
| 356 | +; :Qt Qt |
| 357 | +; :A (DiagonalMatrix/create eigenvectors) |
| 358 | +; :eigenvalues eigenvalues |
| 359 | +; :eigenvectorss eigenvectors} |
| 360 | +; (:return options)))))) |
344 | 361 |
|
345 | 362 | (extend-protocol mp/PNorm
|
346 | 363 | INDArray
|
|
0 commit comments