diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs
index 435540d7..c41d2659 100644
--- a/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Factorization/Cholesky.cs
@@ -54,7 +54,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
var det = Complex.One;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det *= CholeskyFactor[j, j] * CholeskyFactor[j, j];
+ var d = CholeskyFactor.At(j, j);
+ det *= d * d;
}
return det;
@@ -71,7 +72,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
var det = Complex.Zero;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det += 2.0 * CholeskyFactor[j, j].NaturalLogarithm();
+ det += 2.0 * CholeskyFactor.At(j, j).NaturalLogarithm();
}
return det;
diff --git a/src/Numerics/LinearAlgebra/Complex/Matrix.cs b/src/Numerics/LinearAlgebra/Complex/Matrix.cs
index 077e374b..0fdafcac 100644
--- a/src/Numerics/LinearAlgebra/Complex/Matrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Matrix.cs
@@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{
for (var j = 0; j != ColumnCount; j++)
{
- result[i, j] = -At(i, j);
+ result.At(i, j, -At(i, j));
}
}
}
diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/Cholesky.cs
index eef56c06..c86ce18b 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Factorization/Cholesky.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/Cholesky.cs
@@ -54,7 +54,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
var det = Complex32.One;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det *= CholeskyFactor[j, j] * CholeskyFactor[j, j];
+ var d = CholeskyFactor.At(j, j);
+ det *= d * d;
}
return det;
@@ -71,7 +72,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
var det = Complex32.Zero;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det += 2.0f * CholeskyFactor[j, j].NaturalLogarithm();
+ det += 2.0f * CholeskyFactor.At(j, j).NaturalLogarithm();
}
return det;
diff --git a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs
index 37cafee1..d795644d 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs
@@ -296,7 +296,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{
for (var j = 0; j != ColumnCount; j++)
{
- result[i, j] = -At(i, j);
+ result.At(i, j, -At(i, j));
}
}
}
diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Double/Factorization/Cholesky.cs
index 871a2fad..14e29652 100644
--- a/src/Numerics/LinearAlgebra/Double/Factorization/Cholesky.cs
+++ b/src/Numerics/LinearAlgebra/Double/Factorization/Cholesky.cs
@@ -54,7 +54,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
var det = 1.0;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det *= CholeskyFactor[j, j] * CholeskyFactor[j, j];
+ var d = CholeskyFactor.At(j, j);
+ det *= d * d;
}
return det;
@@ -71,7 +72,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
var det = 0.0;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det += 2 * Math.Log(CholeskyFactor[j, j]);
+ det += 2 * Math.Log(CholeskyFactor.At(j, j));
}
return det;
diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs
index 7363e26d..a15f119b 100644
--- a/src/Numerics/LinearAlgebra/Double/Matrix.cs
+++ b/src/Numerics/LinearAlgebra/Double/Matrix.cs
@@ -286,7 +286,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{
for (var j = 0; j != ColumnCount; j++)
{
- result[i, j] = -At(i, j);
+ result.At(i, j, -At(i, j));
}
}
}
diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.cs
index 8b16cf46..c152d219 100644
--- a/src/Numerics/LinearAlgebra/Generic/Matrix.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Matrix.cs
@@ -29,6 +29,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
using System;
using System.Collections.Generic;
using System.Numerics;
+ using System.Runtime;
using System.Text;
using Factorization;
using Numerics;
@@ -36,6 +37,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
using Storage;
using Threading;
+
///
/// Defines the base class for Matrix classes.
///
@@ -166,7 +168,12 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// to get and set values without range checking.
public T this[int row, int column]
{
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
get { return Storage[row, column]; }
+
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
set { Storage[row, column] = value; }
}
@@ -182,6 +189,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
///
/// The requested element.
///
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
public T At(int row, int column)
{
return Storage.At(row, column);
@@ -199,6 +208,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
///
/// The value to set the element to.
///
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
public void At(int row, int column, T value)
{
Storage.At(row, column, value);
diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs
index a0296eb3..6e6eeeaa 100644
--- a/src/Numerics/LinearAlgebra/Generic/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs
@@ -30,8 +30,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
+ using System.Runtime;
using System.Text;
- using Distributions;
using Numerics;
using Properties;
using Storage;
@@ -86,13 +86,20 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// greater than the size of the vector.
public T this[int index]
{
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
get { return Storage[index]; }
+
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
set { Storage[index] = value;}
}
/// Gets the value at the given without range checking..
/// The index of the value to get or set.
- /// The value of the vector at the given .
+ /// The value of the vector at the given .
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
public T At(int index)
{
return Storage.At(index);
@@ -101,6 +108,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Sets the at the given without range checking..
/// The index of the value to get or set.
/// The value to set.
+ [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
+ //[MethodImpl(MethodImplOptions.AggressiveInlining)] .Net 4.5 only
public void At(int index, T value)
{
Storage.At(index, value);
diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/Cholesky.cs b/src/Numerics/LinearAlgebra/Single/Factorization/Cholesky.cs
index 6eddd377..aed2a823 100644
--- a/src/Numerics/LinearAlgebra/Single/Factorization/Cholesky.cs
+++ b/src/Numerics/LinearAlgebra/Single/Factorization/Cholesky.cs
@@ -54,7 +54,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
var det = 1.0f;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det *= CholeskyFactor[j, j] * CholeskyFactor[j, j];
+ var d = CholeskyFactor.At(j, j);
+ det *= d * d;
}
return det;
@@ -71,7 +72,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
var det = 0.0f;
for (var j = 0; j < CholeskyFactor.RowCount; j++)
{
- det += 2.0f * Convert.ToSingle(Math.Log(CholeskyFactor[j, j]));
+ det += 2.0f * Convert.ToSingle(Math.Log(CholeskyFactor.At(j, j)));
}
return det;
diff --git a/src/Numerics/LinearAlgebra/Single/Matrix.cs b/src/Numerics/LinearAlgebra/Single/Matrix.cs
index c4c67f92..db6d1464 100644
--- a/src/Numerics/LinearAlgebra/Single/Matrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/Matrix.cs
@@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{
for (var j = 0; j != ColumnCount; j++)
{
- result[i, j] = -At(i, j);
+ result.At(i, j, -At(i, j));
}
}
}