Changeset 175
- Timestamp:
- 05/22/08 13:24:54 (4 months ago)
- Files:
-
- trunk/QLNet/QLNet/Math/Matrix.cs (modified) (4 diffs)
- trunk/QLNet/QLNet/Math/statistics/convergencestatistics.cs (modified) (3 diffs)
- trunk/QLNet/QLNet/Math/statistics/sequencestatistics.cs (added)
- trunk/QLNet/QLNet/QLNet.csproj (modified) (1 diff)
- trunk/QLNet/Test2008/T_Stats.cs (added)
- trunk/QLNet/Test2008/Test2008.csproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/QLNet/QLNet/Math/Matrix.cs
r110 r175 36 36 37 37 private double[,] data_; 38 public double this[int i, int j] { get { return data_[i, j]; } set { data_[i, j] = value; } } 38 39 public Vector row(int r) { 39 40 Vector result = new Vector(rows_); … … 47 48 result[i] = data_[i, c]; 48 49 return result; 49 } 50 } 51 public Vector diagonal() { 52 int arraySize = Math.Min(rows(), columns()); 53 Vector tmp = new Vector(arraySize); 54 for(int i = 0; i < arraySize; i++) 55 tmp[i] = data_[i,i]; 56 return tmp; 57 } 50 58 #endregion 51 59 … … 90 98 public static Matrix operator +(Matrix m1, Matrix m2) { return operMatrix(ref m1, ref m2, (x, y) => x + y); } 91 99 public static Matrix operator -(Matrix m1, Matrix m2) { return operMatrix(ref m1, ref m2, (x, y) => x - y); } 100 public static Matrix operator *(double value, Matrix m1) { return operValue(ref m1, value, (x, y) => x * y); } 101 public static Matrix operator /(double value, Matrix m1) { return operValue(ref m1, value, (x, y) => x / y); } 92 102 public static Matrix operator *(Matrix m1, double value) { return operValue(ref m1, value, (x, y) => x * y); } 93 103 public static Matrix operator /(Matrix m1, double value) { return operValue(ref m1, value, (x, y) => x / y); } … … 150 160 return result; 151 161 } 162 163 public static Matrix outerProduct(List<double> v1begin, List<double> v2begin) { 164 165 int size1 = v1begin.Count; 166 if (!(size1>0)) throw new ApplicationException("null first vector"); 167 168 int size2 = v2begin.Count; 169 if(!(size2>0)) throw new ApplicationException("null second vector"); 170 171 Matrix result = new Matrix(size1, size2); 172 173 for (int i=0; i<v1begin.Count; i++) 174 for(int j=0; j<v2begin.Count; j++) 175 result[i,j] = v1begin[i] * v2begin[j]; 176 return result; 177 } 152 178 } 153 179 } trunk/QLNet/QLNet/Math/statistics/convergencestatistics.cs
r174 r175 56 56 where T : IGeneralStatistics, new() { 57 57 public ConvergenceStatistics(T stats, DoublingConvergenceSteps rule) : base(stats, rule) { } 58 public ConvergenceStatistics() : base(new DoublingConvergenceSteps()) { } 58 59 public ConvergenceStatistics(DoublingConvergenceSteps rule) : base(rule) { } 59 60 } … … 77 78 } 78 79 79 //public ConvergenceStatistics(U rule = U()) {80 public ConvergenceStatistics() : this(new U()) { } 80 81 public ConvergenceStatistics(U rule) { 81 82 samplingRule_ = rule; … … 89 90 } 90 91 91 //void add(const value_type& value, Real weight = 1.0);92 public void add(double value) { add(value, 1); } 92 93 public void add(double value, double weight) { 93 94 impl_.add(value, weight); trunk/QLNet/QLNet/QLNet.csproj
r174 r175 191 191 <Compile Include="Math\statistics\incrementalstatistics.cs" /> 192 192 <Compile Include="Math\statistics\riskstatistics.cs" /> 193 <Compile Include="Math\statistics\sequencestatistics.cs" /> 193 194 <Compile Include="Math\transformedgrid.cs" /> 194 195 <Compile Include="Math\Vector.cs" /> trunk/QLNet/Test2008/Test2008.csproj
r172 r175 59 59 <Compile Include="T_SampledCurve.cs" /> 60 60 <Compile Include="T_Solvers.cs" /> 61 <Compile Include="T_Stats.cs" /> 61 62 <Compile Include="T_Swaps.cs" /> 62 63 <Compile Include="T_TermStructures.cs" />