public void ComplexMatrixConjugate() { // MATLAB: conj_c = conj(ca3x2) ComplexMatrix u = new ComplexMatrix(new Complex[][] { new Complex[] { 6 + (12 * j), 0 }, new Complex[] { 2 + (4 * j), 12 + (24 * j) }, new Complex[] { 14 + (28 * j), 18 + (36 * j) } }); Assert.That(_ca3X2.Conjugate(), NumericIs.AlmostEqualTo(u), "conj c 1"); Assert.That(_ca3X2.Conjugate(), Is.Not.SameAs(_ca3X2)); Assert.That(_ca3X2.Conjugate().GetArray(), Is.Not.SameAs(_ca3X2.GetArray())); ComplexMatrix uInplace = _ca3X2.Clone(); Complex[][] internalArray = uInplace.GetArray(); uInplace.ConjugateInplace(); Assert.That(uInplace, NumericIs.AlmostEqualTo(u), "conj c 2"); Assert.That(internalArray, Is.Not.SameAs(_ca3X2.GetArray())); Assert.That(internalArray, Is.SameAs(uInplace.GetArray())); }
public void ComplexMatrixHermitianTranspose() { /* 2x3 rectangular case */ // MATLAB: htrans_c = ca3x2' ComplexMatrix u = new ComplexMatrix(new Complex[][] { new Complex[] { 6 + (12 * j), 2 + (4 * j), 14 + (28 * j) }, new Complex[] { 0, 12 + (24 * j), 18 + (36 * j) } }); Assert.That(_ca3X2.HermitianTranspose(), NumericIs.AlmostEqualTo(u), "htrans c 1"); Assert.That(_ca3X2.HermitianTranspose(), Is.Not.SameAs(_ca3X2)); Assert.That(_ca3X2.HermitianTranspose().GetArray(), Is.Not.SameAs(_ca3X2.GetArray())); /* 2x2 square case */ // MATLAB: htrans_c2 = cc2x2' ComplexMatrix v = new ComplexMatrix(new Complex[][] { new Complex[] { 8 + (24 * j), 10 + (30 * j) }, new Complex[] { 9 + (27 * j), 11 + (33 * j) } }); Assert.That(_cc2X2.HermitianTranspose(), NumericIs.AlmostEqualTo(v), "htrans c2 1"); Assert.That(_cc2X2.HermitianTranspose(), Is.Not.SameAs(_cc2X2)); Assert.That(_cc2X2.HermitianTranspose().GetArray(), Is.Not.SameAs(_cc2X2.GetArray())); ComplexMatrix vInplace = _cc2X2.Clone(); Assert.That(vInplace, Is.Not.SameAs(_cc2X2)); Assert.That(vInplace.GetArray(), Is.Not.SameAs(_cc2X2.GetArray())); Complex[][] internalArray = vInplace.GetArray(); vInplace.HermitianTransposeInplace(); Assert.That(vInplace, NumericIs.AlmostEqualTo(v), "htrans c2 2"); Assert.That(vInplace.GetArray(), Is.SameAs(internalArray)); }