/// <summary>Initializes a new instance of the <see cref="SapMatrixDecomposer" /> class. /// </summary> /// <param name="maximalRank">The maximal rank of the resulting matrix.</param> /// <param name="multiDimOptmizer">The multi-dimensional </param> /// <param name="infoOutputDetailLevel">The info-output level of detail.</param> public SapMatrixDecomposer(int maximalRank, OrdinaryMultiDimOptimizer multiDimOptmizer, InfoOutputDetailLevel infoOutputDetailLevel = InfoOutputDetailLevel.Middle) : base(infoOutputDetailLevel) { if (multiDimOptmizer == null) { throw new ArgumentNullException("multiDimOptimizer"); } m_MultiDimOptimizer = multiDimOptmizer; m_InitialDecomposer = new EznMatrixDecomposer(maximalRank); m_Name = new IdentifierString(String.Format("SAP Decomposer; max. rank: {0}", maximalRank)); }
/// <summary>Initializes a new instance of the <see cref="SapMatrixDecomposer" /> class. /// </summary> /// <param name="multiDimOptmizer">The multi-dimensional </param> /// <param name="infoOutputDetailLevel">The info-output level of detail.</param> public SapMatrixDecomposer(OrdinaryMultiDimOptimizer multiDimOptmizer, InfoOutputDetailLevel infoOutputDetailLevel = InfoOutputDetailLevel.Middle) : base(infoOutputDetailLevel) { if (multiDimOptmizer == null) { throw new ArgumentNullException("multiDimOptmizer"); } m_MultiDimOptimizer = multiDimOptmizer; m_InitialDecomposer = new EznMatrixDecomposer(); m_Name = new IdentifierString("SAP Decomposer"); }
public void Create_RebonatoJaeckelExample2_BenchmarkResult() { int n = 3; var rawCorrelationMatrix = new DenseMatrix(n, n, new[] { 1.0, 0.9, 0.7, 0.9, 1.0, 0.3, 0.7, 0.3, 1.0 }); var matrixDecomposer = new EznMatrixDecomposer(BasicComponents.Containers.InfoOutputDetailLevel.Full); PseudoSqrtMatrixDecomposer.State state; var actual = matrixDecomposer.Create(rawCorrelationMatrix, out state); int expectedRank = 2; Assert.That(state.Rank, Is.EqualTo(expectedRank), String.Format("Rank should be {0}, but was {1}.", expectedRank, state.Rank)); var expected = new DenseMatrix(n, state.Rank, new[] { // the values taken from the reference are re-ordered and with a negative sign -0.06238, -0.50292, 0.67290, -0.99805, -0.86434, -0.73974 }); Assert.That(actual.Data.Take(actual.RowCount * actual.ColumnCount).ToArray(), Is.EqualTo(expected.Data).AsCollection.Within(1E-4)); }
public void CreateSymmetric_RebonatoJaeckelExample2_BenchmarkResult() { int n = 3; var rawCorrelationMatrix = new SymmetricMatrix(n, new[] { 1.0, 0.9, 0.7, 1.0, 0.3, 1.0 }); var matrixDecomposer = new EznMatrixDecomposer(); int rank; var actual = matrixDecomposer.Create(rawCorrelationMatrix, out rank); int expectedRank = 2; Assert.That(rank, Is.EqualTo(expectedRank), String.Format("Rank should be {0}, but was {1}.", expectedRank, rank)); var expected = new DenseMatrix(n, rank, new[] { // the values taken from the reference are re-ordered and same(!) columns are with a negative sign -0.06238, -0.50292, 0.67290, 0.99805, 0.86434, 0.73974 }); Assert.That(actual.Data.Take(actual.RowCount * actual.ColumnCount).ToArray(), Is.EqualTo(expected.Data).AsCollection.Within(1E-4)); }
public void Create_RebonatoJaeckelExample1_BenchmarkResult() { int n = 3; var rawCorrelationMatrix = new DenseMatrix(n, n, new[] { 1.0, 0.9, 0.7, 0.9, 1.0, 0.4, 0.7, 0.4, 1.0 }); var matrixDecomposer = new EznMatrixDecomposer(); PseudoSqrtMatrixDecomposer.State state; var actual = matrixDecomposer.Create(rawCorrelationMatrix, out state); Assert.That(state.Rank, Is.EqualTo(n), String.Format("Rank should be {0}, but was {1}.", n, state.Rank)); var expected = new DenseMatrix(n, n, new[] { // the values taken from the reference are re-ordered with a negative sign 0.13192, -0.10021, -0.05389, -0.08718, -0.45536, 0.63329, -0.98742, -0.88465, -0.77203 }); Assert.That(actual.Data, Is.EqualTo(expected.Data).AsCollection.Within(1E-4)); }