public override BenchmarkResult Run(BenchmarkSetup config) { int rows = config.RowCount; int cols = config.ColumnCount; int repeat = config.Repeat; double density = config.Density; bool symmetric = config.Symmetric; var A = Create.SparseMatrix(rows, cols, density, symmetric); var S = CreateSparse.RandomSymmetric(4, 0.5); var result = new BenchmarkResult(); Util.Tic(); var B = S.FastKroneckerProduct(A); result.Time2 = Util.Toc(); Util.Tic(); var C = S.KroneckerProduct(A); result.Time1 = Util.Toc(); result.Success = MatrixComparer.Equals(B, C, EPS); return(result); }
public static SparseMatrix SparseMatrix(int rows, int columns, double density, bool symmetric) { if (symmetric) { return(CreateSparse.RandomSymmetric(rows, density)); } return(CreateSparse.Random(rows, columns, density)); }
public static IStorageAdapter CreateRandom(int rowCount, int columnCount, double density, bool symmetric) { var A = symmetric ? CreateSparse.RandomSymmetric(rowCount, density) : CreateSparse.Random(rowCount, columnCount, density); var norms = ToComplexArray((2 * A.RowNorms(1)).ToArray()); A.FastAddDiagonalMatrix(norms, A); return(new SparseStorageAdapter(A)); }