Changeset 8678 for trunk/sources
- Timestamp:
- 09/21/12 18:45:15 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessRegressionSolutionLineChartView.cs
r8580 r8678 29 29 30 30 namespace HeuristicLab.Algorithms.DataAnalysis.Views { 31 [View("Line Chart 2")]31 [View("Line Chart (95% confidence interval)")] 32 32 [Content(typeof(GaussianProcessRegressionSolution))] 33 33 public partial class GaussianProcessRegressionSolutionLineChartView : DataAnalysisSolutionEvaluationView { -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceConst.cs
r8612 r8678 91 91 } 92 92 93 public double GetCovariance(double[,] x, int i, int j ) {93 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 94 94 return scale; 95 95 } 96 96 97 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {97 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 98 98 yield return 2.0 * scale; 99 99 } 100 100 101 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {101 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 102 102 return scale; 103 103 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs
r8612 r8678 51 51 } 52 52 53 public double GetCovariance(double[,] x, int i, int j ) {54 return Util.ScalarProd(x, i, j );53 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 54 return Util.ScalarProd(x, i, j, 1, columnIndices); 55 55 } 56 56 57 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {57 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 58 58 yield break; 59 59 } 60 60 61 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {61 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 62 62 return Util.ScalarProd(x, i, xt, j); 63 63 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinearArd.cs
r8612 r8678 92 92 } 93 93 94 public double GetCovariance(double[,] x, int i, int j ) {95 return Util.ScalarProd(x, i, j, inverseLength );94 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 95 return Util.ScalarProd(x, i, j, inverseLength, columnIndices); 96 96 } 97 97 98 public IEnumerable<double> GetGradient(double[,] x, int i, int j) { 99 for (int k = 0; k < inverseLength.Length; k++) { 98 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 99 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); 100 101 foreach (int k in columnIndices) { 100 102 yield return -2.0 * x[i, k] * x[j, k] * inverseLength[k] * inverseLength[k]; 101 103 } 102 104 } 103 105 104 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {105 return Util.ScalarProd(x, i, xt, j, inverseLength );106 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 107 return Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices); 106 108 } 107 109 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceMaternIso.cs
r8612 r8678 154 154 } 155 155 156 public double GetCovariance(double[,] x, int i, int j ) {156 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 157 157 double dist = i == j 158 158 ? 0.0 159 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength ));159 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices)); 160 160 return sf2 * m(dist); 161 161 } 162 162 163 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {163 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 164 164 double dist = i == j 165 165 ? 0.0 166 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength ));166 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices)); 167 167 168 168 yield return sf2 * dm(dist); … … 170 170 } 171 171 172 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {173 double dist = Math.Sqrt(Util.SqrDist(x, i, xt, j, Math.Sqrt(d) * inverseLength ));172 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 173 double dist = Math.Sqrt(Util.SqrDist(x, i, xt, j, Math.Sqrt(d) * inverseLength, columnIndices)); 174 174 return sf2 * m(dist); 175 175 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceNoise.cs
r8612 r8678 90 90 } 91 91 92 public double GetCovariance(double[,] x, int i, int j ) {92 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 93 93 return sf2; 94 94 } 95 95 96 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {96 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 97 97 yield return 2 * sf2; 98 98 } 99 99 100 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {100 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 101 101 return 0.0; 102 102 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovariancePeriodic.cs
r8612 r8678 76 76 Name = ItemName; 77 77 Description = ItemDescription; 78 78 79 79 scaleParameter = new HyperParameter<DoubleValue>("Scale", "The scale of the periodic covariance function."); 80 80 inverseLengthParameter = new HyperParameter<DoubleValue>("InverseLength", "The inverse length parameter for the periodic covariance function."); … … 125 125 } 126 126 127 public double GetCovariance(double[,] x, int i, int j) { 128 double k = i == j ? 0.0 : GetDistance(x, x, i, j); 127 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 128 if (columnIndices == null || columnIndices.Count() != 1) 129 throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); 130 double k = i == j ? 0.0 : GetDistance(x, x, i, j, columnIndices); 129 131 k = Math.PI * k / period; 130 132 k = Math.Sin(k) * inverseLength; … … 134 136 } 135 137 136 public IEnumerable<double> GetGradient(double[,] x, int i, int j) { 137 double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j) / period; 138 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 139 if (columnIndices == null || columnIndices.Count() != 1) 140 throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); 141 double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; 138 142 double gradient = Math.Sin(v) * inverseLength; 139 143 gradient *= gradient; … … 144 148 } 145 149 146 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { 147 double k = GetDistance(x, xt, i, j); 150 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 151 if (columnIndices == null || columnIndices.Count() != 1) 152 throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); 153 double k = GetDistance(x, xt, i, j, columnIndices); 148 154 k = Math.PI * k / period; 149 155 k = Math.Sin(k) * inverseLength; … … 153 159 } 154 160 155 private double GetDistance(double[,] x, double[,] xt, int i, int j ) {156 return Math.Sqrt(Util.SqrDist(x, i, xt, j ));161 private double GetDistance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 162 return Math.Sqrt(Util.SqrDist(x, i, xt, j, 1, columnIndices)); 157 163 } 158 164 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProduct.cs
r8620 r8678 76 76 } 77 77 78 public double GetCovariance(double[,] x, int i, int j ) {79 return factors.Select(f => f.GetCovariance(x, i, j )).Aggregate((a, b) => a * b);78 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 79 return factors.Select(f => f.GetCovariance(x, i, j, columnIndices)).Aggregate((a, b) => a * b); 80 80 } 81 81 82 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {83 var covariances = factors.Select(f => f.GetCovariance(x, i, j )).ToArray();82 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 83 var covariances = factors.Select(f => f.GetCovariance(x, i, j, columnIndices)).ToArray(); 84 84 for (int ii = 0; ii < factors.Count; ii++) { 85 foreach (var g in factors[ii].GetGradient(x, i, j )) {85 foreach (var g in factors[ii].GetGradient(x, i, j, columnIndices)) { 86 86 double res = g; 87 87 for (int jj = 0; jj < covariances.Length; jj++) … … 92 92 } 93 93 94 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {95 return factors.Select(f => f.GetCrossCovariance(x, xt, i, j )).Aggregate((a, b) => a * b);94 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 95 return factors.Select(f => f.GetCrossCovariance(x, xt, i, j, columnIndices)).Aggregate((a, b) => a * b); 96 96 } 97 97 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceRationalQuadraticArd.cs
r8615 r8678 135 135 136 136 137 public double GetCovariance(double[,] x, int i, int j ) {137 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 138 138 double d = i == j 139 139 ? 0.0 140 : Util.SqrDist(x, i, j, inverseLength );140 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 141 141 return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); 142 142 } 143 143 144 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {144 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 145 145 double d = i == j 146 146 ? 0.0 147 : Util.SqrDist(x, i, j, inverseLength );147 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 148 148 double b = 1 + 0.5 * d / shape; 149 149 for (int k = 0; k < inverseLength.Length; k++) { … … 154 154 } 155 155 156 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {157 double d = Util.SqrDist(x, i, xt, j, inverseLength );156 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 157 double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); 158 158 return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); 159 159 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceRationalQuadraticIso.cs
r8615 r8678 125 125 126 126 127 public double GetCovariance(double[,] x, int i, int j ) {127 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 128 128 double d = i == j 129 129 ? 0.0 130 : Util.SqrDist(x, i, j, inverseLength );130 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 131 131 return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); 132 132 } 133 133 134 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {134 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 135 135 double d = i == j 136 136 ? 0.0 137 : Util.SqrDist(x, i, j, inverseLength );137 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 138 138 139 139 double b = 1 + 0.5 * d / shape; … … 143 143 } 144 144 145 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {146 double d = Util.SqrDist(x, i, xt, j, inverseLength );145 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 146 double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); 147 147 return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); 148 148 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceScale.cs
r8620 r8678 72 72 this.scaleParameter = new HyperParameter<DoubleValue>("Scale", "The scale parameter."); 73 73 this.covParameter = new ValueParameter<ICovarianceFunction>("CovarianceFunction", "The covariance function that should be scaled.", new CovarianceSquaredExponentialIso()); 74 cov = covParameter.Value; 74 75 75 76 Parameters.Add(this.scaleParameter); … … 106 107 } 107 108 108 public double GetCovariance(double[,] x, int i, int j ) {109 return sf2 * cov.GetCovariance(x, i, j );109 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 110 return sf2 * cov.GetCovariance(x, i, j, columnIndices); 110 111 } 111 112 112 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {113 yield return 2 * sf2 * cov.GetCovariance(x, i, j );114 foreach (var g in cov.GetGradient(x, i, j ))113 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 114 yield return 2 * sf2 * cov.GetCovariance(x, i, j, columnIndices); 115 foreach (var g in cov.GetGradient(x, i, j, columnIndices)) 115 116 yield return sf2 * g; 116 117 } 117 118 118 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {119 return sf2 * cov.GetCrossCovariance(x, xt, i, j );119 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 120 return sf2 * cov.GetCrossCovariance(x, xt, i, j, columnIndices); 120 121 } 121 122 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSquaredExponentialArd.cs
r8615 r8678 110 110 } 111 111 112 public double GetCovariance(double[,] x, int i, int j ) {112 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 113 113 double d = i == j 114 114 ? 0.0 115 : Util.SqrDist(x, i, j, inverseLength );115 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 116 116 return sf2 * Math.Exp(-d / 2.0); 117 117 } 118 118 119 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {119 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 120 120 double d = i == j 121 121 ? 0.0 122 : Util.SqrDist(x, i, j, inverseLength );122 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 123 123 124 124 for (int ii = 0; ii < inverseLength.Length; ii++) { … … 129 129 } 130 130 131 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {132 double d = Util.SqrDist(x, i, xt, j, inverseLength );131 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 132 double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); 133 133 return sf2 * Math.Exp(-d / 2.0); 134 134 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSquaredExponentialIso.cs
r8615 r8678 108 108 109 109 110 public double GetCovariance(double[,] x, int i, int j ) {110 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 111 111 double d = i == j 112 112 ? 0.0 113 : Util.SqrDist(x, i, j, inverseLength );113 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 114 114 return sf2 * Math.Exp(-d / 2.0); 115 115 } 116 116 117 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {117 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 118 118 double d = i == j 119 119 ? 0.0 120 : Util.SqrDist(x, i, j, inverseLength );120 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 121 121 double g = Math.Exp(-d / 2.0); 122 122 yield return sf2 * g * d; … … 124 124 } 125 125 126 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {127 double d = Util.SqrDist(x, i, xt, j, inverseLength );126 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 127 double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); 128 128 return sf2 * Math.Exp(-d / 2.0); 129 129 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs
r8612 r8678 76 76 } 77 77 78 public double GetCovariance(double[,] x, int i, int j ) {79 return terms.Select(t => t.GetCovariance(x, i, j )).Sum();78 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 79 return terms.Select(t => t.GetCovariance(x, i, j, columnIndices)).Sum(); 80 80 } 81 81 82 public IEnumerable<double> GetGradient(double[,] x, int i, int j ) {83 return terms.Select(t => t.GetGradient(x, i, j )).Aggregate(Enumerable.Concat);82 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 83 return terms.Select(t => t.GetGradient(x, i, j, columnIndices)).Aggregate(Enumerable.Concat); 84 84 } 85 85 86 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j ) {87 return terms.Select(t => t.GetCrossCovariance(x, xt, i, j )).Sum();86 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 87 return terms.Select(t => t.GetCrossCovariance(x, xt, i, j, columnIndices)).Sum(); 88 88 } 89 89 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs
r8562 r8678 27 27 int GetNumberOfParameters(int numberOfVariables); 28 28 void SetParameter(double[] hyp); 29 double GetCovariance(double[,] x, int i, int j );30 IEnumerable<double> GetGradient(double[,] x, int i, int j );31 double GetCrossCovariance(double[,] x, double[,] xt, int i, int j );29 double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices = null); 30 IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices = null); 31 double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices = null); 32 32 } 33 33 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs
r8612 r8678 41 41 } 42 42 43 public static double SqrDist(double[,] x, int i, int j, double scale = 1.0 ) {44 return SqrDist(x, i, x, j, scale );43 public static double SqrDist(double[,] x, int i, int j, double scale = 1.0, IEnumerable<int> columnIndices = null) { 44 return SqrDist(x, i, x, j, scale, columnIndices); 45 45 } 46 46 47 public static double SqrDist(double[,] x, int i, double[,] xt, int j, double scale = 1.0 ) {47 public static double SqrDist(double[,] x, int i, double[,] xt, int j, double scale = 1.0, IEnumerable<int> columnIndices = null) { 48 48 double ss = 0.0; 49 for (int k = 0; k < x.GetLength(1); k++) { 49 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); 50 foreach (int k in columnIndices) { 50 51 double d = x[i, k] - xt[j, k]; 51 52 ss += d * d; … … 54 55 } 55 56 56 public static double SqrDist(double[,] x, int i, int j, double[] scale ) {57 public static double SqrDist(double[,] x, int i, int j, double[] scale, IEnumerable<int> columnIndices = null) { 57 58 return SqrDist(x, i, x, j, scale); 58 59 } 59 60 60 public static double SqrDist(double[,] x, int i, double[,] xt, int j, double[] scale ) {61 public static double SqrDist(double[,] x, int i, double[,] xt, int j, double[] scale, IEnumerable<int> columnIndices = null) { 61 62 double ss = 0.0; 62 for (int k = 0; k < x.GetLength(1); k++) { 63 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); 64 foreach (int k in columnIndices) { 63 65 double d = x[i, k] - xt[j, k]; 64 66 ss += d * d * scale[k] * scale[k]; … … 66 68 return ss; 67 69 } 68 public static double ScalarProd(double[,] x, int i, int j, double scale = 1.0 ) {69 return ScalarProd(x, i, x, j, scale );70 public static double ScalarProd(double[,] x, int i, int j, double scale = 1.0, IEnumerable<int> columnIndices = null) { 71 return ScalarProd(x, i, x, j, scale, columnIndices); 70 72 } 71 73 72 public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double scale = 1.0 ) {74 public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double scale = 1.0, IEnumerable<int> columnIndices = null) { 73 75 double sum = 0.0; 74 for (int k = 0; k < x.GetLength(1); k++) { 76 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); 77 foreach (int k in columnIndices) { 75 78 sum += x[i, k] * xt[j, k]; 76 79 } 77 80 return scale * scale * sum; 78 81 } 79 public static double ScalarProd(double[,] x, int i, int j, double[] scale ) {80 return ScalarProd(x, i, x, j, scale );82 public static double ScalarProd(double[,] x, int i, int j, double[] scale, IEnumerable<int> columnIndices = null) { 83 return ScalarProd(x, i, x, j, scale, columnIndices); 81 84 } 82 85 83 public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double[] scale ) {86 public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double[] scale, IEnumerable<int> columnIndices = null) { 84 87 double sum = 0.0; 85 for (int k = 0; k < x.GetLength(1); k++) { 88 if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); 89 foreach (int k in columnIndices) { 86 90 sum += x[i, k] * scale[k] * xt[j, k] * scale[k]; 87 91 }
Note: See TracChangeset
for help on using the changeset viewer.