本文整理汇总了C#中IMatrix类的典型用法代码示例。如果您正苦于以下问题:C# IMatrix类的具体用法?C# IMatrix怎么用?C# IMatrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMatrix类属于命名空间,在下文中一共展示了IMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sum
/// <summary>
/// Сумма элементов матрицы
/// </summary>
/// <param name="matrix">Матрица</param>
/// <returns>Сумма элементов</returns>
public static long Sum(IMatrix<int> matrix)
{
long sum = 0;
foreach (IIndex index in MultiDimensionMatrixEnumerator.Indexes(matrix))
sum += matrix[index];
return sum;
}
示例2: EhCrossPRESS
public void EhCrossPRESS(int[]group, IMatrix XX, IMatrix YY, IMatrix XU, IMatrix YU)
{
IVector meanX,scaleX,meanY,scaleY;
if(_predictedY==null || _predictedY.Rows!=YU.Rows || _predictedY.Columns!=YU.Columns)
_predictedY = new MatrixMath.BEMatrix(YU.Rows,YU.Columns);
MultivariateRegression.PreprocessForAnalysis(_preprocessOptions,_spectralRegions, XX, YY, out meanX, out scaleX, out meanY, out scaleY);
_analysis.AnalyzeFromPreprocessed(XX,YY,_numFactors);
_numFactors = Math.Min(_numFactors,_analysis.NumberOfFactors);
MultivariateRegression.PreprocessSpectraForPrediction(_preprocessOptions,XU,meanX,scaleX);
// allocate the crossPRESS vector here, since now we know about the number of factors a bit more
if(null==_crossPRESS)
_crossPRESS = new double[_numFactors+1]; // one more since we want to have the value at factors=0 (i.e. the variance of the y-matrix)
// for all factors do now a prediction of the remaining spectra
_crossPRESS[0] += MatrixMath.SumOfSquares(YU);
for(int nFactor=1;nFactor<=_numFactors;nFactor++)
{
_analysis.PredictYFromPreprocessed(XU,nFactor,_predictedY);
MultivariateRegression.PostprocessY(_predictedY,meanY,scaleY);
_crossPRESS[nFactor] += MatrixMath.SumOfSquaredDifferences(YU,_predictedY);
}
}
示例3: EnsureMinSelfLoopCount
/// <summary>
/// Ensures a minimum number of self loops exist in the matrix by adding values to the diagonal.
/// </summary>
public static void EnsureMinSelfLoopCount(IMatrix<double> network, int n)
{
int ctr = 0;
// find all non-zeros on diagonal
for (int i = 0; i < network.NodeCount; i++)
{
if (network[i,i]!=0.0)
ctr++;
}
// if that many self loops exist, return
if (ctr >= n)
return;
// else create the needed number of self loops
int needed = n;
if (n < ctr)
needed = ctr - n;
ctr = 0; // re-use ctr variable
do
{
for (int i = 0; i < network.NodeCount; i++)
{
network[i, i] = network[i, i] + 1.0;
ctr++;
if (ctr >= needed)
break;
}
} while (needed >ctr);
}
示例4: RecordValue
public RecordValue(IMatrix matr1, IMatrix matr2, IDrawer dr1, IDrawer dr2)
{
this.matr1 = matr1;
this.matr2 = matr2;
this.dr1 = dr1;
this.dr2 = dr2;
}
示例5: RemoveMatrixRow
public void RemoveMatrixRow(IMatrix matrix, IDBDataSource dBDataSource, int row)
{
dBDataSource.RemoveRecord(row - 1);
// Loads the user interface with current data from the matrix objects data source.
matrix.LoadFromDataSource();
}
示例6: Border
public void Border(IMatrix m)
{
if (matrComp.col_num == matrComp.col_num - 1 && matrComp.row_num == matrComp.row_num - 1)
{
drawer.Border(this);
}
}
示例7: W
/// <summary>
/// Средняя нагрузка при заданных параметрах разбиения матрицы
/// </summary>
/// <param name="matrix">Матрица</param>
/// <param name="partitioning">Параметры разбиения матрицы</param>
/// <returns>Сумма элементов</returns>
public static double W(IMatrix<int> matrix, params int[] partitioning)
{
int N = 1;
for (int i = 0; i < partitioning.Length; i++)
N *= partitioning[i];
return Sum(matrix) / (double)N;
}
示例8: CellValue
public void CellValue(IMatrix m, int row, int col)
{
if (row == r || col == c) { }
else {
drawer.CellValue(this, row, col);
}
}
示例9: SetTransform
public void SetTransform (LinearGradientBrush widget, IMatrix transform)
{
var brush = ((BrushObject)widget.ControlObject);
brush.Matrix = transform;
var newmatrix = brush.InitialMatrix.Clone ();
newmatrix.Multiply (transform.ToSD ());
brush.Brush.Transform = newmatrix;
}
示例10: Inititialize
public void Inititialize()
{
_container = new Mock<IContainer>();
_container.Setup(x => x.GetInstance<IPrimeNumber>()).Returns(new PrimeNumber());
_primeNumber = _container.Object.GetInstance<IPrimeNumber>();
_container.Setup(x => x.GetInstance<IMatrix>()).Returns(new Matrix(_primeNumber));
_matrix = _container.Object.GetInstance<IMatrix>();
}
示例11: WriteMatrix
/// <summary>Write a matrix of floats to a StreamWriter object</summary>
/// <param name="writer">a <see cref="StreamWriter"/></param>
/// <param name="matrix">the matrix of floats to write out</param>
static public void WriteMatrix(this TextWriter writer, IMatrix<float> matrix)
{
writer.WriteLine(matrix.NumberOfRows + " " + matrix.NumberOfColumns);
for (int i = 0; i < matrix.NumberOfRows; i++)
for (int j = 0; j < matrix.NumberOfColumns; j++)
writer.WriteLine(i + " " + j + " " + matrix[i, j].ToString(CultureInfo.InvariantCulture));
writer.WriteLine();
}
示例12: SolutionVisualizerForm
public SolutionVisualizerForm(SplittedMatrix splittedMatrix, IMatrix<int> matrix, ISolution solution, int min, int max, double criterion)
{
InitParameters(splittedMatrix, matrix, solution);
SetSizeOfBitmap();
SetMinMax(min, max);
SetBoundOfValuesOfMatrix(min, max);
SetCriterion(criterion);
settingsEvent();
}
示例13: ReadFromFile
public void ReadFromFile(out IMatrix A, out Vector b, out Vector x_init)
{
// Не хватает проверки path
using (System.IO.StreamReader file = new System.IO.StreamReader(path))
{
var st = file.ReadToEnd().Replace('.',',').Split(new char[] { '\n', ' ', '\t', '\r' },
StringSplitOptions.RemoveEmptyEntries);
int n, m;
if (!int.TryParse(st[0], out n))
throw new Exception("Bad file format");
n = int.Parse(st[0]);
int[] ia = new int[n + 1];
double[] d = new double[n];
double[] rightPart = new double[n];
double[] x0 = new double[n];
long offset = 1;
for (int i = 0; i < n + 1; i++, offset++)
ia[i] = int.Parse(st[offset]);
m = ia[n] - 1;
int[] ja = new int[m];
double[] al = new double[m];
double[] au = new double[m];
for (int i = 0; i < m; i++, offset++)
ja[i] = int.Parse(st[offset]);
if (ia[0] != 0)
{
for (int i = 0; i < n + 1; i++)
ia[i]--;
for (int i = 0; i < m; i++)
ja[i]--;
}
for (int i = 0; i < m; i++,offset++)
al[i] = double.Parse(st[offset]);
for (int i = 0; i < m; i++, offset++)
au[i] = double.Parse(st[offset]);
for (int i = 0; i < n; i++,offset++)
d[i] = double.Parse(st[offset]);
for (int i = 0; i < n; i++,offset++)
rightPart[i] = double.Parse(st[offset]);
for (int i = 0; i < n; i++, offset++)
x0[i] = double.Parse(st[offset]);
A = new RowColumnSparseMatrix(n, ia, ja, al, au, d);
b = new Vector(rightPart);
x_init = new Vector(x0);
}
}
示例14: CellValue
public override void CellValue(IMatrix m, int row, int col)
{
string s = m[row, col].ToString();
Font font = new Font("Arial",12);
SolidBrush brush = new SolidBrush(Color.CornflowerBlue);
RectangleF rect = new RectangleF(x + h*col, y +h*row, h , h);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
g.DrawString(s,font,brush,rect,format);
}
示例15: Matrix
public Matrix(IMatrix x)
{
m = x.ColumnDimension;
n = x.RowDimension;
el = new double[n, m];
for (int row = 0; row < n; row++)
for (int column = 0; column < m; column++)
el[row, column] = x[row, column];
}