public void PlusMultiply_GENDATA_Test1() { var tileSize = 50; var blockMatrix1 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(200, 200), tileSize); var blockMatrix2 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(200, 200), tileSize); var blockMatrix3 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(200, 200), tileSize); var clonedBlockMatrix1 = blockMatrix1.Clone(); var clonedBlockMatrix2 = blockMatrix2.Clone(); var clonedBlockMatrix3 = blockMatrix3.Clone(); var opData1 = new OperationResult<double>(blockMatrix1); var opData2 = new OperationResult<double>(blockMatrix2); var opData3 = new OperationResult<double>(blockMatrix3); Matrix<Matrix<double>> expected = clonedBlockMatrix1.PlusMultiply(clonedBlockMatrix2, clonedBlockMatrix3); OperationResult<double> actual; var plusMultProducer = new PlusMultiply<double>(opData1, opData2, opData3, out actual); var pm = new Manager(plusMultProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data); MatrixHelpers.Compare(expected, actual.Data); }
public void PipelinedStigsFormlerInverse_DATA_Test1() { var tileSize = 30; // TODO: This is lousy precision, optimize BlockTridiagonalMatrixInverse // We are comparing parallel operation to tiled operations, inverting should (probably) result in the same precision. //var delta = 1.0E-8; var delta = 0; var btm = BlockTridiagonalMatrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\ds10x100x200.btm"); // create the expected result through non parallel version var inverter = new TiledSingleThreadedBlockMatrixInverter<double>(); var tiledBtm = btm.Clone().Tile(tileSize); inverter.Invert(tiledBtm); var expected = tiledBtm.Untile(); // get result BlockTridiagonalMatrix<double> actual; var sf = new BlockTridiagonalMatrixInverse<double>(btm, tileSize, out actual); var nonpl = new PipelinedBlockTridiagonalMatrixInverse(sf); var pm = new Manager(nonpl); pm.Start(); pm.Join(); MatrixHelpers.Diff(expected, actual, delta); MatrixHelpers.Compare(expected, actual, delta); }
public void Untile_GENDATA_Test() { var matrixSize = 100; var minBlockSize = 100; var maxBlockSize = 200; var tileSize = 30; var data = BlockTridiagonalMatrix<double>.CreateBlockTridiagonalMatrix<double>(matrixSize, minBlockSize, maxBlockSize, Matrix<double>.CreateNewRandomDoubleMatrix).Tile(tileSize); var tbtmData = Helpers.Init<OperationResult<double>>(data.Size + 1, 3); for (int i = 1; i <= data.Size; i++) { // tile the block to the left of the diagonal if (i > 1) { tbtmData[i][0] = new OperationResult<double>(data[i, i - 1]); } // tile the block on the diagonal tbtmData[i][1] = new OperationResult<double>(data[i, i]); // tile the block to the right of the diagonal if (i < data.Size) { tbtmData[i][2] = new OperationResult<double>(data[i, i + 1]); } } BlockTridiagonalMatrix<double> expected = data.Untile(); BlockTridiagonalMatrix<double> actual = new BlockTridiagonalMatrix<double>(expected.Size); var untileProducer = new UntileOperation<double>(tbtmData, actual); var pm = new Manager(untileProducer); pm.Start(); pm.Join(); for (int i = 1; i <= expected.Size; i++) { if (i > 1) { Assert.AreEqual(expected[i, i - 1], actual[i, i - 1]); } Assert.AreEqual(expected[i, i], actual[i, i]); if (i < expected.Size) { Assert.AreEqual(expected[i, i + 1], actual[i, i + 1]); } } }
public static void PipelinedSlim(MessureContext context) { var tileSize = (int)context.Data["tilesize"]; var threads = (int)context.Data["threads"]; var btm = (BlockTridiagonalMatrix<double>)context.Data["btm"]; BlockTridiagonalMatrix<double> result; var sf = new BlockTridiagonalMatrixInverse<double>(btm, tileSize, out result); var nonpl = new PipelinedBlockTridiagonalMatrixInverse(sf); var pm = new Manager(nonpl, threads); pm.Start(); pm.Join(); }
public void LUFactTest_1500x1500() { var tileSize = 40; // prepare data var data = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a.mat"), tileSize); Matrix<Matrix<double>> expected = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a-LUFactorize-result.mat"), tileSize); var opData1 = new OperationResult<double>(data); OperationResult<double> actual; var mProducer = new LUFactorization<double>(opData1, out actual); var pm = new Manager(mProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data); MatrixHelpers.Compare(expected, actual.Data); }
public void Inverse_GENDATA_Test1() { var tileSize = 30; var diff = 0.0; // prepare data var data = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(200, 200), tileSize); var clonedData = data.Clone(); // the parallel version of Inverse expectes its data to be LU Factorized, the tiled version does not. data = data.GetLU(); var opData1 = new OperationResult<double>(data); Matrix<Matrix<double>> expected = clonedData.Inverse(); OperationResult<double> actual; var mProducer = new Inverse<double>(opData1, out actual); var pm = new Manager(mProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data, diff); MatrixHelpers.Compare(expected, actual.Data); }
public void MinusMatrixInverseMatrixMultiply_MAPLE_Test2() { var tileSize = 5; var delta = 0.000000001; var a = new Matrix<double>(new double[,] { { -32, 9, 25, 50, -40, 3, 66, -11, 73 }, { -92, 71, 80, 26, 95, 31, -23, -70, -88 }, { -60, -59, 87, 16, 63, -45, -78, 25, -69 }, { 19, 57, -34, 22, -64, 75, -53, -61, -98 }, { 43, 64, -59, 51, -24, -84, -35, -79, -9 }, { -16, -74, -77, 91, 32, -88, -28, 39, -16 }, { -49, -91, -11, 78, 40, -21, -32, -98, 11 }, { 95, -30, -39, 90, -6, -65, 86, -76, 49 }, { 29, 17, 72, -90, -10, 41, 56, -14, -52 } }); var b = new Matrix<double>(new double[,] { { 77, 63, -62, -66, -6, -56, 80, -14, -65 }, { 4, -53, -65, -36, 42, 15, 34, 78, -5 }, { -30, 82, -1, 68, -62, 3, 17, -75, -10 }, { 84, 60, 16, 63, 67, 45, 53, -42, 2 }, { 87, 95, 92, 79, -63, 64, -36, 62, -1 }, { -8, -41, 82, -89, -54, 51, 96, -61, -73 }, { -38, -38, -45, 40, -75, 86, 75, 68, 28 }, { -7, 37, -36, 65, -88, -61, -6, -99, -79 }, { 98, 8, -37, 39, 91, 86, -27, -63, -72 } }); // MinusMatrixInverseMatrix expects its second argument to be LU Factorized b = b.GetLU(); var expected = MatrixHelpers.Tile(new Matrix<double>(new[,] { { 0.01984508466, 0.9042399904, 0.3995515772, -0.7745771722, 0.2994725178, 0.1084556411, -0.6575886106, -0.05301668731, 0.5444903099 }, { 1.855372611, -5.371281536, -4.104553393, -0.1121640216, -0.7296221045, -1.180498074, 3.045677622, 0.1386335471, 0.2821013684 }, { 1.929588849, -4.235913487, -1.189842573, -0.4245090055, -0.7875419486, -0.8542334129, 2.365695716, -1.087624087, 0.7376953336 }, { -0.3015200144, 0.06444804897, -1.093050084, 1.295819257, -0.3278095393, -0.09936130892, -0.08586242003, 0.2752136949, -1.135640896 }, { -0.6678456488, 1.635971997, 0.7408829678, -0.03480275626, 0.3196134418, 0.6555494623, -0.4839099415, -0.3891630982, -0.1698423028 }, { 0.9195999547, -1.811264799, 0.7645929720, -0.9267010695, -0.04031193539, 0.2576350183, 0.4513746375, -1.641684280, 0.6576041476 }, { 0.8358290298, 0.4796609017, 0.9546484769, -0.7810311114, 0.6595774182, 0.08541865288, -0.1904549301, -0.9345738811, 0.06621834781 }, { -0.6369792740, 3.263015949, 3.301792682, -1.825297016, 0.8801089887, 0.6821136696, -1.785435645, -1.226781234, 0.4676272889 }, { -0.2239907182, -0.3318901401, -0.4804214610, 0.2182583930, -0.2667527668, -0.6941578781, 0.3641733215, 0.4656006742, -0.08591310567 } }), tileSize); var opData1 = new OperationResult<double>(MatrixHelpers.Tile(a, tileSize)); var opData2 = new OperationResult<double>(MatrixHelpers.Tile(b, tileSize)); OperationResult<double> actual; var nmimmProducer = new MinusMatrixInverseMatrixMultiply<double>(opData1, opData2, out actual); var pm = new Manager(nmimmProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data, delta); MatrixHelpers.Compare(expected, actual.Data, delta); }
static void MinusMatrixInverseMatrixMultiply_GENDATA_Test(int blockSize) { var tileSize = 30; var blockMatrix1 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(blockSize, blockSize), tileSize); var blockMatrix2 = MatrixHelpers.Tile(Matrix<double>.CreateNewRandomDoubleMatrix(blockSize, blockSize), tileSize); var clonedBlockMatrix1 = blockMatrix1.Clone(); var clonedBlockMatrix2 = blockMatrix2.Clone(); // MinusMatrixInverseMatrix expects its second argument to be LU Factorized blockMatrix2 = blockMatrix2.GetLU(); var opData1 = new OperationResult<double>(blockMatrix1); var opData2 = new OperationResult<double>(blockMatrix2); Matrix<Matrix<double>> expected = clonedBlockMatrix1.MinusMatrixInverseMatrixMultiply(clonedBlockMatrix2); OperationResult<double> actual; var nmimmProducer = new MinusMatrixInverseMatrixMultiply<double>(opData1, opData2, out actual); var pm = new Manager(nmimmProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data); MatrixHelpers.Compare(expected, actual.Data); }
static void Main(string[] args) { var tileSize = 40; var d1 = Matrix<double>.DeSerializeFromFile( @"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a.mat"); var d2 = Matrix<double>.DeSerializeFromFile( @"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-b.mat"); // prepare data var data1 = MatrixHelpers.Tile(d1, tileSize); var data2 = MatrixHelpers.Tile(d2, tileSize); var opData1 = new OperationResult<double>(data1); var opData2 = new OperationResult<double>(data2.GetLU()); OperationResult<double> actual; var mProducer = new MinusMatrixInverseMatrixMultiply<double>(opData1, opData2, out actual); var pm = new Manager(mProducer); pm.Start(); pm.Join(); NotNaNOrInfinity(actual.Data); ////foreach (var rowActionGenerator in AbstractOperationGenerator(5, 5)) ////{ //// AbstractOperation op; //// while (!rowActionGenerator.Completed) //// { //// op = rowActionGenerator.Find((x) => true); //// Console.WriteLine(op); //// } //// Console.WriteLine(); //////} //for (int i = 1; i <= 5; i++) //{ // foreach (var s in G_ColumnAbstractActionGenerator(i, 5)) // { // Console.WriteLine(s); // } // Console.WriteLine(); //} }
public void PipelinedStigsFormlerInverse_MAPLE_Test3() { Matrix<double>.MatrixOperations = new DoubleMatrixOperations(); Matrix<Matrix<double>>.MatrixOperations = new TiledMatrixOperations<double>(); var btm = new BlockTridiagonalMatrix<double>(3); btm[1, 1] = new Matrix<double>(new double[,] { { -36, 26, -26, -1, -14, 41, 42, 16, 24, -80 }, { -69, -3, -20, 63, 60, 91, 18, 9, 65, 43 }, { 69, -62, -78, -23, -35, 29, -59, 99, 86, 25 }, { -15, -83, -4, -63, 21, 70, 12, 60, 20, 94 }, { 2, 9, 5, -26, 90, -32, -62, -95, -61, 12 }, { -88, 88, -91, 30, 80, -1, -33, -20, -48, -2 }, { 99, 95, -44, 10, 19, 52, -68, -25, 77, 50 }, { -59, 63, -38, 22, 88, -13, -67, 51, 9, 10 }, { 10, 10, -38, 12, -82, 82, 22, 76, 31, -16 }, { -44, -61, 91, 45, -70, 72, 14, -44, -50, -9 } }); btm[1, 2] = new Matrix<double>(new double[,] { { -97, 28, -79, -85, 19, 81, 48, 23, 18, 71 }, { -92, -48, 9, -19, 25, 35, -60, -67, 18, -50 }, { 73, -63, 45, 57, 17, 80, 51, 28, 63, -17 }, { 44, 27, -10, 83, 81, 20, 20, -81, 86, 35 }, { 92, 58, -5, -45, 89, 39, -46, -36, -51, -26 }, { 73, 2, 47, 68, 92, -35, 35, -88, 51, -86 }, { -39, 54, -54, 58, -2, 26, -54, 91, 38, 50 }, { 62, 47, -72, -43, -46, -74, -17, -62, -38, -94 }, { 11, 90, -79, -85, -29, 13, -25, -94, -19, -97 }, { 61, -41, 75, -85, 9, 32, 78, 27, -55, -38 } }); btm[2, 1] = new Matrix<double>(new double[,] { { -11, -60, 7, -62, -69, 75, 82, 77, 54, -76 }, { 75, -86, 86, 81, 17, -31, -4, -84, 79, 82 }, { 33, 64, -19, 22, -87, -30, 14, -63, -99, -29 }, { 27, -40, -53, 50, 37, -50, 78, 96, -32, 29 }, { 42, -43, -15, 78, 33, 98, -75, 69, -9, 35 }, { -86, 23, -89, -8, -17, 5, -3, 72, 69, -70 }, { -77, 68, 66, -90, 58, -23, 19, 42, 31, -43 }, { -48, -2, 77, -81, -21, 19, 69, 55, -66, -23 }, { -27, 80, -80, -43, 15, -93, -89, 34, -81, -14 }, { -46, -69, -19, -2, -58, 12, 95, -55, 11, 37 } }); btm[2, 2] = new Matrix<double>(new double[,] { { -42, 51, -96, 29, -81, 66, -53, -60, -89, 32 }, { -5, -61, -5, 10, 97, 55, 65, -60, 24, -41 }, { -96, -60, -53, -1, 10, 70, -54, -76, 67, 77 }, { 73, 66, -42, 79, -72, 91, 40, -12, 50, 61 }, { 89, 29, -10, -6, 2, 85, -81, 69, 30, -57 }, { -12, 63, 73, -49, 74, 96, 97, -78, -28, -31 }, { 11, -48, -53, -33, -83, 71, -28, 81, 82, 47 }, { -92, -79, -55, -61, -66, -20, -73, 11, -68, 31 }, { -10, 48, 58, -11, 97, 34, -56, 39, 86, 63 }, { -89, -13, 44, -85, -68, 23, 55, 80, 95, -90 } }); btm[2, 3] = new Matrix<double>(new double[,] { { 65, -59, 83, -65, -87, 62, 52, 73, 33, 27 }, { 7, 5, 57, -82, -96, -70, -18, 90, -5, 23 }, { 59, -94, -97, 12, -80, 55, -52, 33, 69, 70 }, { -22, -74, -13, 47, -27, -17, 26, -25, 19, -69 }, { -58, 28, 10, -6, -48, 24, 37, 10, -87, 20 }, { 82, 33, -65, 2, 28, -55, 31, -99, -75, -7 }, { -18, -73, -80, 40, 10, 65, -15, -50, 50, 65 }, { -8, 77, -39, 20, 88, 81, -46, -11, -98, -86 }, { -43, -9, 25, -64, -53, -52, 97, 79, 80, 98 }, { 21, 74, 33, 71, -20, -49, -22, 61, 85, 19 } }); btm[3, 2] = new Matrix<double>(new double[,] { { 72, 84, -11, -40, -22, 82, -28, -3, 3, 71 }, { -77, -76, 2, -96, -90, 92, 33, 32, 34, -64 }, { -20, -83, 49, 63, 15, 4, 27, 53, 72, 36 }, { 56, 23, 18, 16, 4, -5, -53, 24, 30, -1 }, { 7, -82, 31, 61, 87, -47, -65, -88, -67, 57 }, { 89, 79, -85, 92, 50, -48, 51, 44, 14, -96 }, { -94, -82, 79, 71, -49, 88, -6, 6, 34, -41 }, { -22, -90, 99, 21, 94, -35, 10, -85, 29, -9 }, { -38, 3, 63, -13, -62, -29, -28, 54, -50, -84 }, { 6, -89, 65, -31, -29, 95, -70, 37, 91, -12 } }); btm[3, 3] = new Matrix<double>(new double[,] { { 19, 0, 93, 69, -81, -10, -63, 79, -66, 44 }, { -12, -19, 40, 16, 93, -82, -2, 72, 95, -76 }, { -68, -43, 75, -16, -28, 23, 41, -60, 88, -48 }, { -13, 39, 72, 54, -19, 82, 41, 49, -56, -6 }, { -35, -46, 48, 31, -46, 42, 18, 90, -11, 54 }, { 88, -38, -44, 32, -25, -25, -9, -48, -99, 80 }, { -72, 12, -46, -31, 22, 16, -92, 56, 78, 75 }, { -7, -13, 80, -19, -17, 73, -24, 26, -89, 15 }, { -20, -33, 60, -84, -1, 45, -62, 99, -69, 38 }, { -74, 79, 44, -48, 21, -69, -95, -19, 22, 69 } }); var expected = new BlockTridiagonalMatrix<double>(3); expected[1, 1] = new Matrix<double>(new double[,] { { -0.002390886631, 0.001184082713, 0.003094433027, -0.008109796912, 0.002295725853, 0.001780817527, 0.002379313473, -0.005992391527, 0.003437512585, -0.0006502797392 }, { -0.002654135543, -0.001202577282, -0.0009486829661, -0.003656035770, -0.0007276935858, 0.003820933481, 0.007233861028, -0.00002297749354, 0.002626447116, 0.003744628044 }, { -0.004324157522, 0.008719460530, 0.002761931878, -0.006910857106, -0.001589290727, 0.001923917091, -0.003397796574, -0.007906741570, 0.005009049273, 0.001249301589 }, { 0.002102710941, 0.01262289570, 0.006108064697, -0.006657474172, -0.001097406178, -0.001327943159, -0.002854638527, -0.001291574633, 0.001326448036, 0.004596059032 }, { -0.0005550551413, 0.005138072254, 0.002922980883, -0.006988287288, 0.002504134496, 0.003594504123, -0.0005364535454, -0.004366673895, -0.0007854930675, -0.001310501234 }, { -0.0005415604837, -0.001641168016, -0.001512166484, 0.0002301149246, -0.001396496356, 0.004785412595, 0.002013032151, -0.003666355047, 0.00006840655572, 0.0003228653909 }, { -0.0004940094539, 0.004115393229, 0.002605947403, -0.006229771411, 0.001849255850, 0.004139434811, 0.002582022753, -0.006199591213, 0.003661967423, 0.002421110530 }, { -0.002663157490, 0.01631704167, 0.01228909685, -0.01282016099, 0.00007426467626, 0.001935676153, -0.003353583939, -0.007304180509, 0.006836875150, 0.003314595995 }, { 0.0003003679559, 0.002426156030, 0.002237430226, -0.0001525597771, -0.001401977677, 0.0004157398895, -0.001732255957, -0.002367135428, 0.001893940349, -0.002479874125 }, { -0.0002566472938, -0.006361966928, -0.005205710895, 0.009491276818, 0.002087922598, -0.007948548150, 0.01045927552, 0.01398796238, -0.004074923803, 0.007070621941 } }); expected[1, 2] = new Matrix<double>(new double[,] { { 0.002919178342, -0.001364712512, -0.005487903913, 0.002474431276, 0.001106865983, -0.007442661592, 0.001609440172, 0.00009196412854, 0.002701075955, 0.001652925714 }, { 0.001392270255, 0.001335384209, -0.002016364943, 0.002660200211, -0.001725095329, -0.0002319378075, 0.002310717938, 0.003088258517, 0.002364114073, 0.001235726621 }, { 0.0004517622970, 0.001435640708, -0.005811483056, -0.001646184148, -0.003358230172, -0.007794378663, 0.002153572016, 0.002412733237, 0.005401311465, -0.005015350384 }, { -0.001346780610, -0.0006347235242, -0.001762893755, 0.002708066534, -0.006988182203, -0.007290441341, -0.003210037947, -0.0002581896834, 0.004399358094, -0.005427234281 }, { 0.003196282672, -0.001676075520, -0.006400047817, 0.001792540558, 0.001137788597, -0.007789075438, 0.002381688798, 0.00003523295359, 0.002714743840, 0.001099770172 }, { 0.002562296172, -0.002049267485, -0.001997161763, -0.001854441701, 0.004965791334, -0.002221775234, 0.001514495761, -0.001039001112, -0.001388822025, 0.001644625533 }, { 0.002252637528, 0.0002285806494, -0.004795561109, 0.005859100486, -0.003700770398, -0.005370997198, 0.002485743478, 0.002245712224, 0.002800403181, 0.002651459939 }, { 0.001137210452, -0.001342843660, -0.008693023145, 0.002829667259, -0.007940526745, -0.01348695612, 0.00002160919060, 0.005558818571, 0.01080406230, -0.004260583214 }, { -0.001853766966, 0.002167959255, -0.0004869482946, -0.002244969554, -0.002292225865, 0.001122130727, 0.001915115855, -0.001493557795, -0.001546909302, -0.001852019470 }, { -0.001119318411, 0.001358549964, 0.005417379375, 0.005714277110, -0.001520403536, 0.008887571789, -0.001872548663, 0.001586710524, -0.001524438160, 0.005149573751 } }); expected[2, 1] = new Matrix<double>(new double[,] { { -0.0003928894724, 0.0002692102369, 0.003120823077, -0.001038269777, 0.0001589983814, 0.003348967769, -0.0001930953230, -0.001561978426, 0.0009035692575, 0.002139798834 }, { -0.0004614484116, 0.005120793307, 0.0009909378006, -0.001696941010, 0.0004908039453, -0.00003593834995, -0.002730874848, -0.004616837956, 0.003797063741, -0.0009169629341 }, { -0.005005448563, 0.005347109494, 0.002824817189, -0.005802897760, -0.0004877850653, 0.003421858002, -0.001749263014, -0.008196721984, 0.002570161394, -0.0002959028913 }, { -0.001045829289, -0.001366356849, -0.002003812318, 0.001969965420, -0.001772603358, 0.001125712101, -0.0001514084938, -0.0003041982974, -0.001537772251, -0.001321268136 }, { 0.0007292482461, 0.01578088042, 0.01160741189, -0.01008912909, 0.003491508765, 0.002836529136, -0.004167553079, -0.009883044166, 0.007191607356, 0.002030717925 }, { 0.0007442653058, -0.003397189785, -0.002608589343, 0.003084094896, 0.002456389505, -0.002838208624, 0.003681234456, 0.004343094975, -0.001872938230, 0.002381765907 }, { 0.003327102564, -0.01026621764, -0.004896222394, 0.005048033527, -0.0005572532386, -0.001959570185, 0.005208720753, 0.008321426929, -0.004005758722, 0.002991617847 }, { 0.0006109627806, 0.008596522829, 0.007363640403, -0.006385773458, 0.001321386679, 0.001370548294, -0.001117287899, -0.004851038374, 0.001699139161, 0.002116945724 }, { -0.0001757755539, 0.0003662807972, -0.0005466353247, 0.001316886381, -0.003275356344, 0.002956793322, -0.004152712246, -0.004618868497, 0.001007151905, -0.004147472226 }, { 0.002372053074, -0.001349957951, -0.0009192529070, 0.003067543839, -0.001749771683, -0.001491897258, 0.001098106563, 0.002196103937, -0.003628487870, 0.001458891553 } }); expected[2, 2] = new Matrix<double>(new double[,] { { 0.0002924748799, 0.0004612411320, -0.0005964922959, 0.0009653474910, -0.001896016637, -0.001966041280, 0.001432949725, -0.0002573046909, -0.0001325999243, -0.001025879043 }, { -0.001055529887, -0.0008153591581, -0.002630053713, -0.0006451094302, -0.002689379358, -0.003302764042, -0.0005660749710, -0.0007691781475, 0.002643946802, -0.002868283779 }, { 0.0006273144828, -0.001550843274, -0.004355478396, -0.0003729069348, -0.0005722228536, -0.004113676258, 0.001928976943, -0.0002209884941, 0.003077640704, -0.0006094996857 }, { 0.0005617305292, 0.0004500508772, 0.0007388499078, -0.001017668398, 0.0004985518497, 0.001992115404, -0.001490886415, 0.0001884998044, -0.001327952916, -0.001675512317 }, { -0.001465700768, 0.0002531458282, -0.006295155024, 0.0005351812832, -0.009061083530, -0.01130347533, -0.0006930280928, 0.004574651755, 0.008356048420, -0.004585264651 }, { 0.0007241166339, 0.001290876679, 0.002718445755, 0.002333292567, 0.0005609206301, 0.005780626179, -0.0006323161143, 0.0007989014448, -0.001318143202, 0.0007526075980 }, { 0.0007792265008, 0.0006388606909, 0.001559627851, 0.001994837284, 0.002964095622, 0.005195245677, -0.0002193545216, -0.001350866028, -0.003019839712, 0.004021985943 }, { -0.0006086818966, -0.0005024453870, -0.003433534159, 0.0007251372609, -0.004542747485, -0.006353840565, -0.0001311441738, 0.003055012791, 0.004643554983, -0.001321658858 }, { -0.001165055743, 0.0002821969386, 0.0006527644123, -0.002932970744, 0.002128798284, -0.001921925166, 0.001823440721, -0.002316628109, -0.0004639976657, -0.001627444463 }, { -0.0002378090203, -0.0009621965189, 0.001494872283, 0.0005289029809, -0.0005948512006, 0.0008402967828, -0.0007465031081, -0.001578994461, -0.0008716299268, -0.0009046774018 } }); expected[2, 3] = new Matrix<double>(new double[,] { { -0.0003203527013, -0.001283959440, -0.002466048613, 0.001219785303, 0.00004220238643, -0.001035681250, -0.002683945793, -0.002095215661, 0.0004543793643, 0.001923608361 }, { 0.004623022959, -0.001800757472, -0.0003769103571, 0.0004631960426, -0.006189696111, 0.0005586609426, 0.003159399735, -0.0003261915732, -0.0009290538431, -0.004046989443 }, { 0.005137774592, -0.001998412645, -0.003409117389, -0.006279956851, -0.005735724359, -0.002170066734, 0.001636185441, 0.005161778131, -0.003487773977, -0.004600185560 }, { 0.0002663213699, 0.001261002975, 0.002677232684, 0.002966880806, 0.001221177754, 0.001778894819, 0.002392449127, -0.003871227640, 0.0004572292322, 0.0002179906923 }, { 0.007323076736, -0.005222762662, -0.001576172434, -0.003440487751, -0.008981677282, 0.004297512938, 0.003237645957, 0.002430478919, -0.005669522062, -0.006057135734 }, { -0.002902653598, 0.002075164528, 0.002386146111, 0.004721800396, 0.003303391241, 0.0009135913261, 0.001190687325, -0.001512840053, 0.001746702819, 0.003177336126 }, { -0.004995536399, 0.001639506334, 0.0002650495929, -0.00007338801699, 0.004660143463, -0.0008040340897, 0.0007083567905, 0.003671967110, 0.0007306662971, 0.001751063384 }, { 0.003777516785, -0.003290470011, -0.0001907766549, -0.001967093878, -0.004989988359, 0.002900092685, 0.0006780792972, -0.0007864266467, -0.0008366431886, -0.002913221271 }, { 0.001628783577, 0.001486261031, -0.0009690521560, 0.001099830125, -0.004108471987, -0.001319254680, -0.001520358399, -0.0001787836700, -0.0001580611494, -0.001000083280 }, { -0.0007936292014, -0.0003839227090, -0.001568210521, 0.001548004608, 0.001502122938, -0.002163027927, -0.001899060354, -0.001130722060, 0.0008613986290, 0.002200895353 } }); expected[3, 2] = new Matrix<double>(new double[,] { { 0.003912301448, -0.002254162749, -0.004746805736, 0.001523565564, -0.009147705072, -0.01169653127, -0.001161096338, 0.002858413427, 0.007978761801, -0.003358723982 }, { 0.002159639807, 0.0007414359567, -0.002284169136, 0.0005908335989, -0.001035714492, -0.001864441648, -0.001518573180, 0.002533259993, 0.001811251223, 0.001683850646 }, { 0.001607172082, -0.001451802364, -0.0002145940398, 0.002121702859, -0.003695976902, -0.00001699852406, -0.003206465237, -0.0001784220808, 0.001037012493, -0.0002305646181 }, { -0.001400063604, -0.001635682109, -0.001404312470, -0.0007290491985, 0.0009366659323, -0.0006072033281, 0.0002864933545, 0.0001983725319, -0.0001473010719, 0.001257469203 }, { -0.001153811881, -0.002810967645, 0.0006555359039, 0.002676162604, -0.006420593478, -0.0006534082576, -0.002889362376, -0.002450120954, 0.0005677608586, -0.003977114053 }, { 0.0003048783375, -0.0008867091114, 0.0005700628200, 0.002802439329, -0.005356933898, -0.002652482540, -0.001074465890, 0.0007026617657, 0.001629094099, -0.0006750694897 }, { 0.001955785416, 0.0008296705959, 0.004589038448, 0.001239930819, 0.008541379552, 0.01148760727, 0.001080959492, -0.003719994731, -0.004934504916, 0.005261357572 }, { -0.0002734462775, 0.001419104494, -0.001996940661, -0.001620315999, -0.0005299914736, -0.004378732723, 0.001212914337, 0.0007500041760, 0.001942513680, -0.001648090709 }, { 0.001587023753, -0.001659678032, -0.006330520567, 0.001355116726, -0.009783389734, -0.01286837231, -0.0007407076222, 0.002309898448, 0.007928596406, -0.003279140150 }, { 0.001765429685, -0.002168964493, 0.002370022938, 0.003499710713, 0.001124573558, 0.004768892033, -0.0008485203017, -0.003868556015, -0.001451705598, 0.003888339837 } }); expected[3, 3] = new Matrix<double>(new double[,] { { 0.006795680721, -0.003345499683, -0.007641172897, -0.004353925957, -0.01410339266, 0.003869228511, 0.001769547911, 0.008694746891, -0.009154466413, -0.004659479776 }, { -0.0002725263809, -0.002959167310, -0.003322278044, 0.0004765092169, -0.002958780732, -0.0006945064862, 0.002740262240, 0.002976602695, -0.005787844252, 0.0008060767293 }, { -0.0003756413772, 0.001418378431, 0.002663785813, 0.003734373141, -0.0003388411208, 0.003562850775, 0.0009321072150, 0.004444501696, -0.001190270584, 0.003442954998 }, { 0.004039788990, 0.001287781270, 0.0009522293080, -0.001279976216, 0.001300881754, 0.001758181043, 0.002749120995, 0.001911703271, -0.004371407110, -0.003363517961 }, { -0.005319281401, 0.003021257099, -0.003479613784, 0.009788730650, -0.0002040771298, 0.003391715239, 0.001123177698, 0.0004507254914, 0.001170687060, 0.004565306107 }, { -0.002337367218, -0.003582973591, -0.0007427825444, 0.006569960214, -0.003852050310, 0.0008362366927, 0.002960503379, 0.003435767612, -0.0003888959350, -0.0006628691683 }, { -0.01171054500, 0.005373504183, 0.0005243112333, 0.005642595478, 0.01110609246, -0.002431802483, -0.004155759571, -0.0003052253043, 0.003181794947, 0.005337586877 }, { 0.003376376559, 0.0005831196346, -0.004326307426, -0.0007281127829, -0.001730844195, -0.001642138679, 0.0003542778432, -0.002287586078, 0.0001262407869, -0.004046488793 }, { 0.006630818431, -0.005185274071, -0.003289414099, -0.004179922095, -0.01135382023, 0.002054978228, 0.005249680383, 0.004398316503, -0.008808737275, -0.005440853080 }, { -0.008411006367, 0.001087800435, -0.002960391419, 0.003597340279, 0.006752210806, 0.002439721898, 0.0009924718875, 0.005708681188, 0.00001933099521, 0.007118558356 } }); var tileSize = 4; var delta = 1.0E-11; BlockTridiagonalMatrix<double> actual; var sf = new BlockTridiagonalMatrixInverse<double>(btm, tileSize, out actual); var pl = new PipelinedBlockTridiagonalMatrixInverse(sf); var pm = new Manager(pl); pm.Start(); pm.Join(); MatrixHelpers.Diff(expected, actual, delta); MatrixHelpers.Compare(expected, actual, delta); }
public void Inverse_MAPLE_100x100Test() { var tilesize = 30; var delta = 1.0E-11; var data = Matrix<double>.ReadFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\Maple Test Data\a-100x100.csv"); var expected = Matrix<double>.ReadFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\Maple Test Data\a-inverse-100x100.csv"); var tiledData = MatrixHelpers.Tile(data, tilesize); tiledData = tiledData.GetLU(); var opData1 = new OperationResult<double>(tiledData); OperationResult<double> actualOR; var mProducer = new Inverse<double>(opData1, out actualOR); var pm = new Manager(mProducer, 1); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actualOR); var actual = MatrixHelpers.Untile(actualOR.Data); MatrixHelpers.Diff(expected, actual, delta); MatrixHelpers.Compare(expected, actual, delta); }
public void NonPipelinedStigsFormlerInverseTest2() { var data = new Matrix<double>(new double[,] { {-29, -74, -54, -88, -51, 35, 69, -3, -26}, {9, 13, -17, 91, 51, -26, -15, -62, -20}, {81, 32, -25, -62, 38, -86, 2, -83, -78}, {35, 48, 78, -94, -38, 50, -88, 9, -4}, {80, -60, 23, 27, -19, -94, 99, 88, 5}, {20, 51, -67, 18, -55, -97, -59, 95, -91}, {39, 20, 28, 18, 71, -38, 10, 63, -44}, {-35, -46, -81, 63, -50, -36, -44, 10, -38}, {26, 35, -36, 86, -17, -69, 26, -61, -38} }); var tileSize = 3; var delta = 1.0E-11; var btm = new BlockTridiagonalMatrix<double>(1); btm[1, 1] = data; var expected = new BlockTridiagonalMatrix<double>(1); expected[1, 1] = new Matrix<double>(new double[,] { { 0.02192015945, 0.07998061455, -0.008445925650, 0.008710218509, 0.01971795582, 0.03369912515, -0.03788966209, -0.04047526651, -0.03443211738 }, { 0.001285473093, 0.006475451796, -0.003107785784, -0.002406763251, -0.002156769941, 0.01009704045, -0.006583144946, -0.01506901599, 0.0005728805958 }, { -0.01701324231, -0.06216985719, 0.005607568490, 0.003398502231, -0.01075343654, -0.03286856797, 0.03576146110, 0.03544270502, 0.03293953991 }, { 0.003728644331, 0.01491375624, -0.006042286532, 0.002970447471, 0.003023926186, 0.003526862044, -0.002322515396, -0.003817996172, 0.0001485894513 }, { -0.0005615412594, 0.007838447265, 0.002333491962, -0.004784087453, -0.0007533342828, 0.002142041231, 0.0004894987124, -0.004087439707, -0.009735593520 }, { 0.02230167876, 0.05874030688, -0.01264627160, 0.008130435740, 0.008704109428, 0.02306863101, -0.02105124873, -0.03019428258, -0.02060130358 }, { 0.003804072365, -0.005281366040, -0.002279134971, -0.002468192455, -0.0007855692333, -0.001365582163, 0.003990170913, -0.004396507733, 0.008058069508 }, { 0.003848095322, 0.01266542130, -0.004489737629, -0.0005820329480, 0.003474043788, 0.009709450206, -0.004204219769, -0.008854978380, -0.009093319451 }, { -0.003080045444, 0.01922614978, -0.00006146877238, -0.006131531678, 0.006953761372, 0.01211106349, -0.02363878097, -0.01592950229, -0.01834293801 } }); BlockTridiagonalMatrix<double> actual; var sf = new BlockTridiagonalMatrixInverse<double>(btm, tileSize, out actual); var nonpl = new NonPipelinedBlockTridiagonalMatrixInverse(sf); var pm = new Manager(nonpl); pm.Start(); pm.Join(); MatrixHelpers.Diff(expected, actual, delta); MatrixHelpers.Compare(expected, actual, delta); }
//[TestMethod] // todo: commented out due to performance when running all tests public void NonPipelinedStigsFormlerInverse_GENDATA_Test2() { var tileSize = 30; var delta = 1.0E-8; var matrixSize = 1; var minBlockSize = 1000; var maxBlockSize = 1000; var btm = BlockTridiagonalMatrix<double>.CreateBlockTridiagonalMatrix<double>(matrixSize, minBlockSize, maxBlockSize, Matrix<double>.CreateNewRandomDoubleMatrix); // create the expected result through non parallel version var inverter = new TiledSingleThreadedBlockMatrixInverter<double>(); var tiledBtm = btm.Clone().Tile(tileSize); inverter.Invert(tiledBtm); var expected = tiledBtm.Untile(); // get result BlockTridiagonalMatrix<double> actual; var sf = new BlockTridiagonalMatrixInverse<double>(btm, tileSize, out actual); var nonpl = new NonPipelinedBlockTridiagonalMatrixInverse(sf); var pm = new Manager(nonpl); pm.Start(); pm.Join(); //MatrixHelpers.Diff(expected, actual, delta); MatrixHelpers.Compare(expected, actual, delta); MatrixHelpers.Diff(expected, actual, delta); }
public void MinusMatrixInverseMatrixMultiply_1500x1500() { var tileSize = 40; // prepare data var data1 = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a.mat"), tileSize); var data2 = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-b.mat"), tileSize); Matrix<Matrix<double>> expected = MatrixHelpers.Tile(Matrix<double>.DeSerializeFromFile(@"C:\Users\eh\Documents\KU\Inversion-of-Block-Tridiagonal-Matrices\Dataset\m1500x1500-a_b-MinusMatrixInverseMatrixMultiply-result.mat"), tileSize); var opData1 = new OperationResult<double>(data1); var opData2 = new OperationResult<double>(data2.GetLU()); OperationResult<double> actual; var mProducer = new MinusMatrixInverseMatrixMultiply<double>(opData1, opData2, out actual); var pm = new Manager(mProducer); pm.Start(); pm.Join(); MatrixHelpers.IsDone(actual); MatrixHelpers.Diff(expected, actual.Data); MatrixHelpers.Compare(expected, actual.Data); }
private static void Runner(IProducer<Action> producer, int threadCount) { var pm = new Manager(producer, threadCount); pm.Start(); pm.Join(); }