public void GetParametricMatrix_Test_BenchmarkMatrix()
        {
            int n    = 3;
            int rank = 2;

            var expected = new DenseMatrix(n, rank, new[] {  // matrix B taken from the reference
                0.99805, 0.86434, 0.73974,
                0.06238, 0.50292, -0.67290
            });

            var theta = new double[n * (rank - 1)];

            SapMatrixDecomposer.GetAngleParameter(expected, theta);

            var actual = new DenseMatrix(n, rank);

            SapMatrixDecomposer.GetParametricMatrix(theta, actual);

            Assert.That(actual.Data, Is.EqualTo(expected.Data).AsCollection.Within(1E-4));
        }
        public void GetAngleParameter_ParametricMatrix_BenchmarkParameter()
        {
            var expected = new[] { // original parameter \theta
                1.6844, 1.6088, 1.4688, 1.4435, 1.5051, 1.6365, 1.6981, 1.6728, 1.5328, 1.4571,
                1.7328, 1.6828, 1.5810, 1.4708, 1.3957, 1.3957, 1.4708, 1.5810, 1.6828, 1.7328,
                1.2775, 1.2965, 1.3444, 1.4267, 1.5203, 1.6213, 1.7149, 1.7972, 1.8451, 1.8640
            };

            int n    = 10;
            int rank = 4;

            var b = new DenseMatrix(n, rank);

            SapMatrixDecomposer.GetParametricMatrix(expected, b);  // b = B(\theta)

            var actual = new double[n * (rank - 1)];

            SapMatrixDecomposer.GetAngleParameter(b, actual); // determine \theta* such that B(\theta*)  = b

            Assert.That(actual, Is.EqualTo(expected).AsCollection.Within(1E-4));
        }