Пример #1
0
        public void TestSVD()
        {
            var a           = _lap.CreateMatrix(256, 128, (x, y) => x * y).AsIndexable();
            var svd         = a.Svd();
            var reducedSize = Enumerable.Range(0, 32).ToList();

            var u    = svd.U.GetNewMatrixFromRows(reducedSize);
            var s    = _lap.CreateDiagonalMatrix(svd.S.AsIndexable().Values.Take(reducedSize.Count).ToArray());
            var vt   = svd.VT.GetNewMatrixFromColumns(reducedSize);
            var us   = u.TransposeThisAndMultiply(s);
            var usvt = us.TransposeAndMultiply(vt);

            Assert.AreEqual(a.RowCount, usvt.RowCount);
            Assert.AreEqual(a.ColumnCount, usvt.ColumnCount);
        }