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


C# DoubleMatrix.Clone方法代码示例

本文整理汇总了C#中DoubleMatrix.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleMatrix.Clone方法的具体用法?C# DoubleMatrix.Clone怎么用?C# DoubleMatrix.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoubleMatrix的用法示例。


在下文中一共展示了DoubleMatrix.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override ICData Run()
        {
            List<Point> sourcePoints = Utilities.ExtractPoints(m_Image1, TresholdColor);
            List<Point> targetPoints = Utilities.ExtractPoints(m_Image2, TresholdColor);
            m_sourceMatrix = Utilities.ListToMatrix(sourcePoints);
            m_targetMatrix = Utilities.ListToMatrix(targetPoints);

            m_commonSize = new Size(Math.Max(m_Image1.Width, m_Image2.Width), Math.Max(m_Image1.Height, m_Image2.Height));

            PCAMatching matching = new PCAMatching(new DoubleMatrix((Matrix<double>)m_sourceMatrix.Clone()), m_targetMatrix);
            matching.Calculate();

            CPCAresultData retResult = new CPCAresultData(m_sourceMatrix, matching.Result, m_commonSize, matching);
            retResult.IncludeSource = IncludeSource;
            return retResult;
        }
开发者ID:array-cwhite,项目名称:shape-matching,代码行数:16,代码来源:CPCA.cs

示例2: CalculateVariableImpactMatrix

    private DoubleMatrix CalculateVariableImpactMatrix(IRun[] runs, string[] runNames) {
      DoubleMatrix matrix = null;
      IEnumerable<DoubleMatrix> allVariableImpacts = (from run in runs
                                                      select run.Results[variableImpactResultName]).Cast<DoubleMatrix>();
      IEnumerable<string> variableNames = (from variableImpact in allVariableImpacts
                                           from variableName in variableImpact.RowNames
                                           select variableName)
                                          .Distinct();
      // filter variableNames: only include names that have at least one non-zero value in a run
      List<string> variableNamesList = (from variableName in variableNames
                                        where GetVariableImpacts(variableName, allVariableImpacts).Any(x => !x.IsAlmost(0.0))
                                        select variableName)
                                       .ToList();

      List<string> statictics = new List<string> { "Median Rank", "Mean", "StdDev", "pValue" };
      List<string> columnNames = new List<string>(runNames);
      columnNames.AddRange(statictics);
      int numberOfRuns = runs.Length;

      matrix = new DoubleMatrix(variableNamesList.Count, numberOfRuns + statictics.Count);
      matrix.SortableView = true;
      matrix.ColumnNames = columnNames;

      // calculate statistics
      List<List<double>> variableImpactsOverRuns = (from variableName in variableNamesList
                                                    select GetVariableImpacts(variableName, allVariableImpacts).ToList())
                                             .ToList();
      List<List<double>> variableRanks = (from variableName in variableNamesList
                                          select GetVariableImpactRanks(variableName, allVariableImpacts).ToList())
                                      .ToList();
      if (variableImpactsOverRuns.Count() > 0) {
        // the variable with the worst median impact value is chosen as the reference variable
        // this is problematic if all variables are relevant, however works often in practice
        List<double> referenceImpacts = (from impacts in variableImpactsOverRuns
                                         let avg = impacts.Median()
                                         orderby avg
                                         select impacts)
                                         .First();
        // for all variables
        for (int row = 0; row < variableImpactsOverRuns.Count; row++) {
          // median rank
          matrix[row, numberOfRuns] = variableRanks[row].Median();
          // also show mean and std.dev. of relative variable impacts to indicate the relative difference in impacts of variables
          matrix[row, numberOfRuns + 1] = Math.Round(variableImpactsOverRuns[row].Average(), 3);
          matrix[row, numberOfRuns + 2] = Math.Round(variableImpactsOverRuns[row].StandardDeviation(), 3);

          double leftTail = 0; double rightTail = 0; double bothTails = 0;
          // calc differences of impacts for current variable and reference variable
          double[] z = new double[referenceImpacts.Count];
          for (int i = 0; i < z.Length; i++) {
            z[i] = variableImpactsOverRuns[row][i] - referenceImpacts[i];
          }
          // wilcoxon signed rank test is used because the impact values of two variables in a single run are not independent
          alglib.wsr.wilcoxonsignedranktest(z, z.Length, 0, ref bothTails, ref leftTail, ref rightTail);
          matrix[row, numberOfRuns + 3] = Math.Round(bothTails, 4);
        }
      }

      // fill matrix with impacts from runs
      for (int i = 0; i < runs.Length; i++) {
        IRun run = runs[i];
        DoubleMatrix runVariableImpacts = (DoubleMatrix)run.Results[variableImpactResultName];
        for (int j = 0; j < runVariableImpacts.Rows; j++) {
          int rowIndex = variableNamesList.FindIndex(s => s == runVariableImpacts.RowNames.ElementAt(j));
          if (rowIndex > -1) {
            matrix[rowIndex, i] = Math.Round(runVariableImpacts[j, 0], 3);
          }
        }
      }
      // sort by median
      var sortedMatrix = (DoubleMatrix)matrix.Clone();
      var sortedIndexes = from i in Enumerable.Range(0, sortedMatrix.Rows)
                          orderby matrix[i, numberOfRuns]
                          select i;

      int targetIndex = 0;
      foreach (var sourceIndex in sortedIndexes) {
        for (int c = 0; c < matrix.Columns; c++)
          sortedMatrix[targetIndex, c] = matrix[sourceIndex, c];
        targetIndex++;
      }
      sortedMatrix.RowNames = sortedIndexes.Select(i => variableNamesList[i]);

      return sortedMatrix;
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:85,代码来源:RunCollectionVariableImpactView.cs

示例3: translate

        private DoubleMatrix translate(DoubleMatrix i_CenteredMatrix, double i_Angle, double i_XScale, double i_YSale)
        {
            DoubleMatrix retResult = new DoubleMatrix((Matrix<double>)i_CenteredMatrix.Clone());

            DoubleMatrix rotateMatrix = new DoubleMatrix(2, 2);
            rotateMatrix[0, 0] = Math.Cos(i_Angle);
            rotateMatrix[0, 1] = -1 * Math.Sin(i_Angle);
            rotateMatrix[1, 0] = Math.Sin(i_Angle);
            rotateMatrix[1, 1] = Math.Cos(i_Angle);
            DoubleMatrix scaleMatrix = new DoubleMatrix(2, 2);
            scaleMatrix.Init(0);
            scaleMatrix[0, 0] = i_XScale;
            scaleMatrix[1, 1] = i_YSale;

            DoubleMatrix transform = scaleMatrix * rotateMatrix;
            return transform * retResult;
        }
开发者ID:array-cwhite,项目名称:shape-matching,代码行数:17,代码来源:PCAmatching.cs


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