当前位置: 首页>>代码示例>>C#>>正文


C# IMatrix类代码示例

本文整理汇总了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;
 }
开发者ID:sergey-and-valya,项目名称:load-balancing,代码行数:12,代码来源:Utilities.cs

示例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);
      }
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:26,代码来源:CrossValidationWorker.cs

示例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);
        }
开发者ID:BgRva,项目名称:Blob1,代码行数:35,代码来源:BasicMatrixGenerator.cs

示例4: RecordValue

 public RecordValue(IMatrix matr1, IMatrix matr2, IDrawer dr1, IDrawer dr2)
 {
     this.matr1 = matr1;
       this.matr2 = matr2;
       this.dr1 = dr1;
       this.dr2 = dr2;
 }
开发者ID:DariaRoschina,项目名称:MatrixShablon,代码行数:7,代码来源:RecordValue.cs

示例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();
		}
开发者ID:ozeraydin57,项目名称:Addon-SAP-B1-Default,代码行数:7,代码来源:MatrixController.cs

示例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);
     }
 }
开发者ID:DariaRoschina,项目名称:MatrixShablon,代码行数:7,代码来源:HideDecorator.cs

示例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;
        }
开发者ID:sergey-and-valya,项目名称:load-balancing,代码行数:14,代码来源:Utilities.cs

示例8: CellValue

        public void CellValue(IMatrix m, int row, int col)
        {
            if (row == r || col == c) { }
                   else {

                drawer.CellValue(this, row, col);
            }
        }
开发者ID:DariaRoschina,项目名称:MatrixShablon,代码行数:8,代码来源:HideDecorator.cs

示例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;
		}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:8,代码来源:LinearGradientBrushHandler.cs

示例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>();
 }
开发者ID:richardwebs,项目名称:PrimeNumber,代码行数:8,代码来源:MatrixTests.cs

示例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();
		}
开发者ID:WisonHuang,项目名称:MyMediaLite,代码行数:11,代码来源:MatrixExtensions.cs

示例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();
 }
开发者ID:sergey-and-valya,项目名称:load-balancing,代码行数:9,代码来源:SolutionVisualizerForm.cs

示例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);
            }
        }
开发者ID:SLAEPM23,项目名称:SLAE,代码行数:56,代码来源:FileManager.cs

示例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);
 }
开发者ID:DariaRoschina,项目名称:MatrixShablon,代码行数:10,代码来源:Sheme.cs

示例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];

        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:11,代码来源:Matrix.cs


注:本文中的IMatrix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。