Input M x N matrix.
The computation is based on SVD and any singular values less than tolerance are treated as zero.
Moore-Penrose pseudoinverse matrix
import mir.ndslice; auto a = [ 64, 2, 3, 61, 60, 6, 9, 55, 54, 12, 13, 51, 17, 47, 46, 20, 21, 43, 40, 26, 27, 37, 36, 30, 32, 34, 35, 29, 28, 38, 41, 23, 22, 44, 45, 19, 49, 15, 14, 52, 53, 11, 8, 58, 59, 5, 4, 62].sliced(8, 6); auto b = a.pinv; auto result = [ 0.0177, -0.0165, -0.0164, 0.0174, 0.0173, -0.0161, -0.0160, 0.0170, -0.0121, 0.0132, 0.0130, -0.0114, -0.0112, 0.0124, 0.0122, -0.0106, -0.0055, 0.0064, 0.0060, -0.0043, -0.0040, 0.0049, 0.0045, -0.0028, -0.0020, 0.0039, 0.0046, -0.0038, -0.0044, 0.0064, 0.0070, -0.0063, -0.0086, 0.0108, 0.0115, -0.0109, -0.0117, 0.0139, 0.0147, -0.0141, 0.0142, -0.0140, -0.0149, 0.0169, 0.0178, -0.0176, -0.0185, 0.0205].sliced(6, 8); import mir.math.common: approxEqual; import mir.algorithm.iteration: all; assert(b.all!((a, b) => approxEqual(a, b, 1e-2, 1e-2))(result));
Computes Moore-Penrose pseudoinverse of matrix.