- Timestamp:
- 09/23/12 00:31:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Nca/Matrix.cs
r8471 r8681 70 70 71 71 public Matrix Transpose() { 72 var result = new Matrix(Transpose(values, Columns, Rows), Columns, Rows); 73 return result; 72 return new Matrix(Transpose(values, Columns, Rows), Columns, Rows); 74 73 } 75 74 … … 125 124 } 126 125 127 public double VectorLength() { 128 return Math.Sqrt(SquaredVectorLength()); 129 } 130 131 public double SquaredVectorLength() { 132 if (Rows != 1) throw new ArgumentException("Length only works on vectors."); 126 public double EuclideanNorm() { 127 return Math.Sqrt(SumOfSquares()); 128 } 129 130 public double SumOfSquares() { 133 131 return values.Sum(x => x * x); 134 132 } … … 137 135 if (Rows != 1 || other.Rows != 1) throw new ArgumentException("OuterProduct can only be applied to vectors."); 138 136 return Transpose().Multiply(other); 137 } 138 139 public IEnumerable<double> ColumnSums() { 140 return Transpose().RowSums(); 141 } 142 143 public IEnumerable<double> RowSums() { 144 var sum = 0.0; 145 int counter = 0; 146 foreach (var v in values) { 147 sum += v; 148 counter++; 149 if (counter == Rows) { 150 yield return sum; 151 sum = 0.0; 152 counter = 0; 153 } 154 } 139 155 } 140 156
Note: See TracChangeset
for help on using the changeset viewer.