public void Mat() { CSqMatrix mat = new CSqMatrix(new Complex[, ] { { 11, 12, 4 }, { 0, 9, 30 }, { 40, 5, 3 } }); Complex a = new Complex(1, 2); (mat * a).Show(); }
public void Minors() { CSqMatrix mat = new CSqMatrix(new Complex[, ] { { new Complex(6, 4), 12, 4 }, { 0, 9, 30 }, { 409, 5, 3 } }); mat.GetMinMat(1, 1).Show(); "".Show(); mat.GetMinMat(1, 2).Show(); "".Show(); mat.GetMinMat(2, 2).Show(); "".Show(); mat.GetMinMat(3, 2).Show(); "".Show(); }
public void InvertMat() { CSqMatrix mat = new CSqMatrix(new Complex[, ] { { 11, 12, 4 }, { 0, 9, 30 }, { 40, 5, 3 } }); double n1 = (mat.Invert() * mat - SqMatrix.E(3)).CubeNorm; n1.Show(); double n2 = (mat.InvertSum * mat - SqMatrix.E(3)).CubeNorm; n2.Show(); Assert.IsTrue(n1 <= 1e-6 && n2 <= 1e-6); }
public void ReverseColAndOthersMet() { CSqMatrix mat = new CSqMatrix(new Complex[, ] { { new Complex(1, 4), 12, 4 }, { 0, 9, 30 }, { 40, 5, 3 } }); mat.ReversColumns(1, 2); mat.Show(); "".Show(); mat.MultplyRows(2, 1).Show(); mat.GetColumn(0).Show(); mat.GetColumn(1).Show(); mat.GetColumn(2).Show(); }
public void DupTest() { CSqMatrix mas = new CSqMatrix(new Complex[, ] { { 1, 2 }, { 3, 2 } }); var s = mas.dup; s[1, 1] = 4; //mas.Show(); //s.Show(); double[] r = new double[] { 1, 2, 3, 4 }; var t = r.Dup(); t[0] = 0; r.Show(); t.Show(); }
public void Dets() { CSqMatrix mat = new CSqMatrix(new Complex[, ] { { new Complex(6, 4), 12, 4 }, { 0, 9, 30 }, { 409, 5, 3 } }); DateTime t1 = DateTime.Now, t2; mat.Det.Show(); t2 = DateTime.Now; (t2 - t1).Show(); mat.DetByMathNet.Show(); t1 = DateTime.Now; (t1 - t2).Show(); }
public void SpeedMatrixOp() { CSqMatrix s = new CSqMatrix(new Complex[, ] { { new Complex(1), new Complex(1e8), new Complex(1e17) }, { new Complex(1e-14), new Complex(2, 1), new Complex(1e54) }, { new Complex(1), new Complex(1e13), new Complex(1e17) } } ); CSqMatrix d = new CSqMatrix(s); d[1, 1] = 1e42; // Stopwatch t = new Stopwatch(); // t.Restart(); // for(int i = 0; i < 10000; i++) // { // s.FastAdd(d); //} // t.ElapsedMilliseconds.Show(); Stopwatch t = new Stopwatch(); t.Restart(); s /= 100000; d /= 100000; for (int i = 0; i < 10000; i++) { s.FastAdd(d); } s *= 100000; t.ElapsedMilliseconds.Show(); }