diff --git a/Sources/Accord.Math/Matrix/Matrix.Product.Generated.cs b/Sources/Accord.Math/Matrix/Matrix.Product.Generated.cs
index 4af589137..bf88c8a75 100644
--- a/Sources/Accord.Math/Matrix/Matrix.Product.Generated.cs
+++ b/Sources/Accord.Math/Matrix/Matrix.Product.Generated.cs
@@ -20619,7 +20619,7 @@ public static int DotAndDot(this int[] rowVector, int[][] matrix, int[] columnVe
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this int[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this int[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -20629,48 +20629,51 @@ public static unsafe int DotAndDot(this int[] rowVector, int[,] matrix, int[] co
#endif
int result = 0;
- fixed (int* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -20726,7 +20729,7 @@ public static double DotAndDot(this int[] rowVector, int[][] matrix, double[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this int[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this int[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -20736,48 +20739,51 @@ public static unsafe double DotAndDot(this int[] rowVector, int[,] matrix, doubl
#endif
double result = 0;
- fixed (int* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -20833,7 +20839,7 @@ public static float DotAndDot(this int[] rowVector, int[][] matrix, float[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this int[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this int[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -20843,48 +20849,51 @@ public static unsafe float DotAndDot(this int[] rowVector, int[,] matrix, float[
#endif
float result = 0;
- fixed (int* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -20940,7 +20949,7 @@ public static int DotAndDot(this int[] rowVector, double[][] matrix, int[] colum
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this int[] rowVector, double[,] matrix, int[] columnVector)
+ public static int DotAndDot(this int[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -20950,48 +20959,51 @@ public static unsafe int DotAndDot(this int[] rowVector, double[,] matrix, int[]
#endif
int result = 0;
- fixed (int* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21047,7 +21059,7 @@ public static double DotAndDot(this int[] rowVector, double[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this int[] rowVector, double[,] matrix, double[] columnVector)
+ public static double DotAndDot(this int[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21057,48 +21069,51 @@ public static unsafe double DotAndDot(this int[] rowVector, double[,] matrix, do
#endif
double result = 0;
- fixed (int* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21154,7 +21169,7 @@ public static float DotAndDot(this int[] rowVector, double[][] matrix, float[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this int[] rowVector, double[,] matrix, float[] columnVector)
+ public static float DotAndDot(this int[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21164,48 +21179,51 @@ public static unsafe float DotAndDot(this int[] rowVector, double[,] matrix, flo
#endif
float result = 0;
- fixed (int* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21261,7 +21279,7 @@ public static double DotAndDot(this int[] rowVector, float[][] matrix, int[] col
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this int[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this int[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21271,48 +21289,51 @@ public static unsafe double DotAndDot(this int[] rowVector, float[,] matrix, int
#endif
double result = 0;
- fixed (int* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21368,7 +21389,7 @@ public static double DotAndDot(this int[] rowVector, float[][] matrix, float[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this int[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this int[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21378,48 +21399,51 @@ public static unsafe double DotAndDot(this int[] rowVector, float[,] matrix, flo
#endif
double result = 0;
- fixed (int* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21475,7 +21499,7 @@ public static double DotAndDot(this int[] rowVector, float[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this int[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this int[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21485,48 +21509,51 @@ public static unsafe double DotAndDot(this int[] rowVector, float[,] matrix, dou
#endif
double result = 0;
- fixed (int* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (int* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ int* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21582,7 +21609,7 @@ public static double DotAndDot(this double[] rowVector, double[][] matrix, doubl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this double[] rowVector, double[,] matrix, double[] columnVector)
+ public static double DotAndDot(this double[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21592,48 +21619,51 @@ public static unsafe double DotAndDot(this double[] rowVector, double[,] matrix,
#endif
double result = 0;
- fixed (double* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21689,7 +21719,7 @@ public static int DotAndDot(this double[] rowVector, double[][] matrix, int[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this double[] rowVector, double[,] matrix, int[] columnVector)
+ public static int DotAndDot(this double[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21699,48 +21729,51 @@ public static unsafe int DotAndDot(this double[] rowVector, double[,] matrix, in
#endif
int result = 0;
- fixed (double* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21796,7 +21829,7 @@ public static float DotAndDot(this double[] rowVector, double[][] matrix, float[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this double[] rowVector, double[,] matrix, float[] columnVector)
+ public static float DotAndDot(this double[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21806,48 +21839,51 @@ public static unsafe float DotAndDot(this double[] rowVector, double[,] matrix,
#endif
float result = 0;
- fixed (double* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -21903,7 +21939,7 @@ public static double DotAndDot(this double[] rowVector, int[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this double[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this double[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -21913,48 +21949,51 @@ public static unsafe double DotAndDot(this double[] rowVector, int[,] matrix, do
#endif
double result = 0;
- fixed (double* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22010,7 +22049,7 @@ public static int DotAndDot(this double[] rowVector, int[][] matrix, int[] colum
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this double[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this double[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22020,48 +22059,51 @@ public static unsafe int DotAndDot(this double[] rowVector, int[,] matrix, int[]
#endif
int result = 0;
- fixed (double* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22117,7 +22159,7 @@ public static float DotAndDot(this double[] rowVector, int[][] matrix, float[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this double[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this double[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22127,48 +22169,51 @@ public static unsafe float DotAndDot(this double[] rowVector, int[,] matrix, flo
#endif
float result = 0;
- fixed (double* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22224,7 +22269,7 @@ public static double DotAndDot(this double[] rowVector, float[][] matrix, double
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this double[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this double[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22234,48 +22279,51 @@ public static unsafe double DotAndDot(this double[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (double* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22331,7 +22379,7 @@ public static double DotAndDot(this double[] rowVector, float[][] matrix, float[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this double[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this double[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22341,48 +22389,51 @@ public static unsafe double DotAndDot(this double[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (double* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22438,7 +22489,7 @@ public static double DotAndDot(this double[] rowVector, float[][] matrix, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this double[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this double[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22448,48 +22499,51 @@ public static unsafe double DotAndDot(this double[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (double* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (double* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ double* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22545,7 +22599,7 @@ public static double DotAndDot(this float[] rowVector, float[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this float[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22555,48 +22609,51 @@ public static unsafe double DotAndDot(this float[] rowVector, float[,] matrix, f
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22652,7 +22709,7 @@ public static double DotAndDot(this float[] rowVector, float[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this float[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22662,48 +22719,51 @@ public static unsafe double DotAndDot(this float[] rowVector, float[,] matrix, d
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22759,7 +22819,7 @@ public static double DotAndDot(this float[] rowVector, float[][] matrix, int[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this float[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22769,48 +22829,51 @@ public static unsafe double DotAndDot(this float[] rowVector, float[,] matrix, i
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -22866,7 +22929,7 @@ public static double DotAndDot(this float[] rowVector, double[][] matrix, float[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix, float[] columnVector)
+ public static double DotAndDot(this float[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -22876,155 +22939,51 @@ public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix,
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
-
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
-
- return result;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ float* pr = r;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
- ///
- /// Computes the product a*B*c of a row vector a,
- /// a square matrix B and a column vector c.
- ///
- ///
- /// The left vector a.
- /// The square matrix B.
- /// The column vector c.
- ///
- /// The product a*B*c of the given vector a,
- /// matrix B and vector c.
- ///
-#if NET45 || NET46 || NET462 || NETSTANDARD
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
-#endif
- public static double DotAndDot(this float[] rowVector, double[][] matrix, double[] columnVector)
- {
-#if DEBUG
- if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
- throw new DimensionMismatchException();
-#endif
- double sum = 0;
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
- for (int i = 0; i < rowVector.Length; i++)
- {
- double s = 0;
- for (int j = 0; j < columnVector.Length; j++)
- s += (double)((double)matrix[i][j] * (double)columnVector[j]);
- sum += (double)((double)rowVector[i] * (double)s);
- }
-
- return sum;
- }
-
- ///
- /// Computes the product a*B*c of a row vector a,
- /// a square matrix B and a column vector c.
- ///
- ///
- /// The left vector a.
- /// The square matrix B.
- /// The column vector c.
- ///
- /// The product a*B*c of the given vector a,
- /// matrix B and vector c.
- ///
-#if NET45 || NET46 || NET462 || NETSTANDARD
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
-#endif
- public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix, double[] columnVector)
- {
- int cols = matrix.Columns();
- int rows = matrix.Rows();
-#if DEBUG
- if (rowVector.Length != rows || cols != columnVector.Length)
- throw new DimensionMismatchException();
-#endif
- double result = 0;
-
- fixed (float* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
-
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
-
return result;
}
@@ -23046,7 +23005,7 @@ public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this float[] rowVector, double[][] matrix, int[] columnVector)
+ public static double DotAndDot(this float[] rowVector, double[][] matrix, double[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
@@ -23080,7 +23039,7 @@ public static double DotAndDot(this float[] rowVector, double[][] matrix, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix, int[] columnVector)
+ public static double DotAndDot(this float[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23090,48 +23049,51 @@ public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix,
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ float* pr = r;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23153,7 +23115,7 @@ public static unsafe double DotAndDot(this float[] rowVector, double[,] matrix,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this float[] rowVector, int[][] matrix, float[] columnVector)
+ public static double DotAndDot(this float[] rowVector, double[][] matrix, int[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
@@ -23187,7 +23149,7 @@ public static double DotAndDot(this float[] rowVector, int[][] matrix, float[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, float[] columnVector)
+ public static double DotAndDot(this float[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23197,48 +23159,51 @@ public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, flo
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23260,7 +23225,7 @@ public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, flo
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this float[] rowVector, int[][] matrix, int[] columnVector)
+ public static double DotAndDot(this float[] rowVector, int[][] matrix, float[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
@@ -23294,7 +23259,7 @@ public static double DotAndDot(this float[] rowVector, int[][] matrix, int[] col
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, int[] columnVector)
+ public static double DotAndDot(this float[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23304,48 +23269,51 @@ public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, int
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23367,7 +23335,7 @@ public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, int
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this float[] rowVector, int[][] matrix, double[] columnVector)
+ public static double DotAndDot(this float[] rowVector, int[][] matrix, int[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
@@ -23401,7 +23369,7 @@ public static double DotAndDot(this float[] rowVector, int[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this float[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23411,48 +23379,51 @@ public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, dou
#endif
double result = 0;
- fixed (float* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23474,20 +23445,20 @@ public static unsafe double DotAndDot(this float[] rowVector, int[,] matrix, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static long DotAndDot(this long[] rowVector, long[][] matrix, long[] columnVector)
+ public static double DotAndDot(this float[] rowVector, int[][] matrix, double[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- long sum = 0;
+ double sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- long s = 0;
+ double s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (long)((long)matrix[i][j] * (long)columnVector[j]);
- sum += (long)((long)rowVector[i] * (long)s);
+ s += (double)((double)matrix[i][j] * (double)columnVector[j]);
+ sum += (double)((double)rowVector[i] * (double)s);
}
return sum;
@@ -23508,7 +23479,7 @@ public static long DotAndDot(this long[] rowVector, long[][] matrix, long[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long DotAndDot(this long[] rowVector, long[,] matrix, long[] columnVector)
+ public static double DotAndDot(this float[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23516,50 +23487,53 @@ public static unsafe long DotAndDot(this long[] rowVector, long[,] matrix, long[
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- long result = 0;
-
- fixed (long* r = rowVector)
- fixed (long* a = matrix)
- fixed (long* c = columnVector)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- long sum1 = 0, sum2 = 0;
- long* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (long)((long)(*pa1++) * (long)(*pc));
- sum2 += (long)((long)(*pa2++) * (long)(*pc));
- pc++;
- }
-
- result += (long)((long)(*pr++) * sum1);
- result += (long)((long)(*pr++) * sum2);
+ double result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (float* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ float* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- long sum = 0;
- long* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (long)((long)(*pa1++) * (long)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (long)((long)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23581,20 +23555,20 @@ public static unsafe long DotAndDot(this long[] rowVector, long[,] matrix, long[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this long[] rowVector, long[][] matrix, double[] columnVector)
+ public static long DotAndDot(this long[] rowVector, long[][] matrix, long[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double sum = 0;
+ long sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- double s = 0;
+ long s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (double)((double)matrix[i][j] * (double)columnVector[j]);
- sum += (double)((double)rowVector[i] * (double)s);
+ s += (long)((long)matrix[i][j] * (long)columnVector[j]);
+ sum += (long)((long)rowVector[i] * (long)s);
}
return sum;
@@ -23615,7 +23589,7 @@ public static double DotAndDot(this long[] rowVector, long[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, long[,] matrix, double[] columnVector)
+ public static long DotAndDot(this long[] rowVector, long[,] matrix, long[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23623,50 +23597,53 @@ public static unsafe double DotAndDot(this long[] rowVector, long[,] matrix, dou
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double result = 0;
-
- fixed (long* r = rowVector)
- fixed (long* a = matrix)
- fixed (double* c = columnVector)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ long result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (long* a = matrix)
+ fixed (long* c = columnVector)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ long sum1 = 0, sum2 = 0;
+ long* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (long)((long)(*pa1++) * (long)(*pc));
+ sum2 += (long)((long)(*pa2++) * (long)(*pc));
+ pc++;
+ }
+
+ result += (long)((long)(*pr++) * sum1);
+ result += (long)((long)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ long sum = 0;
+ long* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (long)((long)(*pa1++) * (long)(*pc++));
+ result += (long)((long)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23688,20 +23665,20 @@ public static unsafe double DotAndDot(this long[] rowVector, long[,] matrix, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static int DotAndDot(this long[] rowVector, long[][] matrix, int[] columnVector)
+ public static double DotAndDot(this long[] rowVector, long[][] matrix, double[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- int sum = 0;
+ double sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- int s = 0;
+ double s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (int)((int)matrix[i][j] * (int)columnVector[j]);
- sum += (int)((int)rowVector[i] * (int)s);
+ s += (double)((double)matrix[i][j] * (double)columnVector[j]);
+ sum += (double)((double)rowVector[i] * (double)s);
}
return sum;
@@ -23722,7 +23699,7 @@ public static int DotAndDot(this long[] rowVector, long[][] matrix, int[] column
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this long[] rowVector, long[,] matrix, int[] columnVector)
+ public static double DotAndDot(this long[] rowVector, long[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23730,50 +23707,53 @@ public static unsafe int DotAndDot(this long[] rowVector, long[,] matrix, int[]
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- int result = 0;
-
- fixed (long* r = rowVector)
- fixed (long* a = matrix)
- fixed (int* c = columnVector)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
+ double result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (long* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23795,20 +23775,20 @@ public static unsafe int DotAndDot(this long[] rowVector, long[,] matrix, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static float DotAndDot(this long[] rowVector, long[][] matrix, float[] columnVector)
+ public static int DotAndDot(this long[] rowVector, long[][] matrix, int[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- float sum = 0;
+ int sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- float s = 0;
+ int s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (float)((float)matrix[i][j] * (float)columnVector[j]);
- sum += (float)((float)rowVector[i] * (float)s);
+ s += (int)((int)matrix[i][j] * (int)columnVector[j]);
+ sum += (int)((int)rowVector[i] * (int)s);
}
return sum;
@@ -23829,7 +23809,7 @@ public static float DotAndDot(this long[] rowVector, long[][] matrix, float[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this long[] rowVector, long[,] matrix, float[] columnVector)
+ public static int DotAndDot(this long[] rowVector, long[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23837,50 +23817,53 @@ public static unsafe float DotAndDot(this long[] rowVector, long[,] matrix, floa
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- float result = 0;
-
- fixed (long* r = rowVector)
- fixed (long* a = matrix)
- fixed (float* c = columnVector)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
+ int result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (long* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -23902,20 +23885,20 @@ public static unsafe float DotAndDot(this long[] rowVector, long[,] matrix, floa
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static long DotAndDot(this long[] rowVector, double[][] matrix, long[] columnVector)
+ public static float DotAndDot(this long[] rowVector, long[][] matrix, float[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- long sum = 0;
+ float sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- long s = 0;
+ float s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (long)((long)matrix[i][j] * (long)columnVector[j]);
- sum += (long)((long)rowVector[i] * (long)s);
+ s += (float)((float)matrix[i][j] * (float)columnVector[j]);
+ sum += (float)((float)rowVector[i] * (float)s);
}
return sum;
@@ -23936,7 +23919,7 @@ public static long DotAndDot(this long[] rowVector, double[][] matrix, long[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long DotAndDot(this long[] rowVector, double[,] matrix, long[] columnVector)
+ public static float DotAndDot(this long[] rowVector, long[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -23944,50 +23927,53 @@ public static unsafe long DotAndDot(this long[] rowVector, double[,] matrix, lon
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- long result = 0;
-
- fixed (long* r = rowVector)
- fixed (double* a = matrix)
- fixed (long* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- long sum1 = 0, sum2 = 0;
- long* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (long)((long)(*pa1++) * (long)(*pc));
- sum2 += (long)((long)(*pa2++) * (long)(*pc));
- pc++;
- }
-
- result += (long)((long)(*pr++) * sum1);
- result += (long)((long)(*pr++) * sum2);
+ float result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (long* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- long sum = 0;
- long* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (long)((long)(*pa1++) * (long)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (long)((long)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24009,20 +23995,20 @@ public static unsafe long DotAndDot(this long[] rowVector, double[,] matrix, lon
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this long[] rowVector, double[][] matrix, double[] columnVector)
+ public static long DotAndDot(this long[] rowVector, double[][] matrix, long[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double sum = 0;
+ long sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- double s = 0;
+ long s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (double)((double)matrix[i][j] * (double)columnVector[j]);
- sum += (double)((double)rowVector[i] * (double)s);
+ s += (long)((long)matrix[i][j] * (long)columnVector[j]);
+ sum += (long)((long)rowVector[i] * (long)s);
}
return sum;
@@ -24043,7 +24029,7 @@ public static double DotAndDot(this long[] rowVector, double[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, double[,] matrix, double[] columnVector)
+ public static long DotAndDot(this long[] rowVector, double[,] matrix, long[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24051,50 +24037,163 @@ public static unsafe double DotAndDot(this long[] rowVector, double[,] matrix, d
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double result = 0;
+ long result = 0;
- fixed (long* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- long* pr = r;
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (long* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ long* pr = r;
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ long sum1 = 0, sum2 = 0;
+ long* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (long)((long)(*pa1++) * (long)(*pc));
+ sum2 += (long)((long)(*pa2++) * (long)(*pc));
+ pc++;
+ }
+
+ result += (long)((long)(*pr++) * sum1);
+ result += (long)((long)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ long sum = 0;
+ long* pc = c;
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ for (int j = 0; j < cols; j++)
+ sum += (long)((long)(*pa1++) * (long)(*pc++));
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ result += (long)((long)(*pr++) * sum);
+ }
+ }
+ }
+
+ return result;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
- result += (double)((double)(*pr++) * sum);
- }
+
+ ///
+ /// Computes the product a*B*c of a row vector a,
+ /// a square matrix B and a column vector c.
+ ///
+ ///
+ /// The left vector a.
+ /// The square matrix B.
+ /// The column vector c.
+ ///
+ /// The product a*B*c of the given vector a,
+ /// matrix B and vector c.
+ ///
+#if NET45 || NET46 || NET462 || NETSTANDARD
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#endif
+ public static double DotAndDot(this long[] rowVector, double[][] matrix, double[] columnVector)
+ {
+#if DEBUG
+ if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
+ throw new DimensionMismatchException();
+#endif
+ double sum = 0;
+
+ for (int i = 0; i < rowVector.Length; i++)
+ {
+ double s = 0;
+ for (int j = 0; j < columnVector.Length; j++)
+ s += (double)((double)matrix[i][j] * (double)columnVector[j]);
+ sum += (double)((double)rowVector[i] * (double)s);
}
+ return sum;
+ }
+
+ ///
+ /// Computes the product a*B*c of a row vector a,
+ /// a square matrix B and a column vector c.
+ ///
+ ///
+ /// The left vector a.
+ /// The square matrix B.
+ /// The column vector c.
+ ///
+ /// The product a*B*c of the given vector a,
+ /// matrix B and vector c.
+ ///
+#if NET45 || NET46 || NET462 || NETSTANDARD
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#endif
+ public static double DotAndDot(this long[] rowVector, double[,] matrix, double[] columnVector)
+ {
+ int cols = matrix.Columns();
+ int rows = matrix.Rows();
+#if DEBUG
+ if (rowVector.Length != rows || cols != columnVector.Length)
+ throw new DimensionMismatchException();
+#endif
+ double result = 0;
+
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ long* pr = r;
+
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
+
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24150,7 +24249,7 @@ public static int DotAndDot(this long[] rowVector, double[][] matrix, int[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this long[] rowVector, double[,] matrix, int[] columnVector)
+ public static int DotAndDot(this long[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24160,48 +24259,51 @@ public static unsafe int DotAndDot(this long[] rowVector, double[,] matrix, int[
#endif
int result = 0;
- fixed (long* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24257,7 +24359,7 @@ public static float DotAndDot(this long[] rowVector, double[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this long[] rowVector, double[,] matrix, float[] columnVector)
+ public static float DotAndDot(this long[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24267,48 +24369,51 @@ public static unsafe float DotAndDot(this long[] rowVector, double[,] matrix, fl
#endif
float result = 0;
- fixed (long* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24364,7 +24469,7 @@ public static long DotAndDot(this long[] rowVector, int[][] matrix, long[] colum
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long DotAndDot(this long[] rowVector, int[,] matrix, long[] columnVector)
+ public static long DotAndDot(this long[] rowVector, int[,] matrix, long[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24374,48 +24479,51 @@ public static unsafe long DotAndDot(this long[] rowVector, int[,] matrix, long[]
#endif
long result = 0;
- fixed (long* r = rowVector)
- fixed (int* a = matrix)
- fixed (long* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- long sum1 = 0, sum2 = 0;
- long* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (long)((long)(*pa1++) * (long)(*pc));
- sum2 += (long)((long)(*pa2++) * (long)(*pc));
- pc++;
- }
-
- result += (long)((long)(*pr++) * sum1);
- result += (long)((long)(*pr++) * sum2);
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (long* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ long* pr = r;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ long sum1 = 0, sum2 = 0;
+ long* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (long)((long)(*pa1++) * (long)(*pc));
+ sum2 += (long)((long)(*pa2++) * (long)(*pc));
+ pc++;
+ }
+
+ result += (long)((long)(*pr++) * sum1);
+ result += (long)((long)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- long sum = 0;
- long* pc = c;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ long sum = 0;
+ long* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (long)((long)(*pa1++) * (long)(*pc++));
-
- result += (long)((long)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (long)((long)(*pa1++) * (long)(*pc++));
+ result += (long)((long)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24471,7 +24579,7 @@ public static int DotAndDot(this long[] rowVector, int[][] matrix, int[] columnV
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this long[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this long[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24481,48 +24589,51 @@ public static unsafe int DotAndDot(this long[] rowVector, int[,] matrix, int[] c
#endif
int result = 0;
- fixed (long* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24578,7 +24689,7 @@ public static double DotAndDot(this long[] rowVector, int[][] matrix, double[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this long[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24588,48 +24699,51 @@ public static unsafe double DotAndDot(this long[] rowVector, int[,] matrix, doub
#endif
double result = 0;
- fixed (long* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24685,7 +24799,7 @@ public static float DotAndDot(this long[] rowVector, int[][] matrix, float[] col
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this long[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this long[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24695,48 +24809,51 @@ public static unsafe float DotAndDot(this long[] rowVector, int[,] matrix, float
#endif
float result = 0;
- fixed (long* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24792,7 +24909,7 @@ public static double DotAndDot(this long[] rowVector, float[][] matrix, long[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, long[] columnVector)
+ public static double DotAndDot(this long[] rowVector, float[,] matrix, long[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24802,48 +24919,51 @@ public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, lo
#endif
double result = 0;
- fixed (long* r = rowVector)
- fixed (float* a = matrix)
- fixed (long* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- long* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (long* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- long* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ long* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ long* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -24899,7 +25019,7 @@ public static double DotAndDot(this long[] rowVector, float[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this long[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -24909,48 +25029,51 @@ public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, fl
#endif
double result = 0;
- fixed (long* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ long* pr = r;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25006,7 +25129,7 @@ public static double DotAndDot(this long[] rowVector, float[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this long[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25016,48 +25139,51 @@ public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, do
#endif
double result = 0;
- fixed (long* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25113,7 +25239,7 @@ public static double DotAndDot(this long[] rowVector, float[][] matrix, int[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this long[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25123,48 +25249,51 @@ public static unsafe double DotAndDot(this long[] rowVector, float[,] matrix, in
#endif
double result = 0;
- fixed (long* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (long* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ long* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25220,7 +25349,7 @@ public static decimal DotAndDot(this decimal[] rowVector, decimal[][] matrix, de
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe decimal DotAndDot(this decimal[] rowVector, decimal[,] matrix, decimal[] columnVector)
+ public static decimal DotAndDot(this decimal[] rowVector, decimal[,] matrix, decimal[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25230,48 +25359,51 @@ public static unsafe decimal DotAndDot(this decimal[] rowVector, decimal[,] matr
#endif
decimal result = 0;
- fixed (decimal* r = rowVector)
- fixed (decimal* a = matrix)
- fixed (decimal* c = columnVector)
- {
- decimal* pa1 = a;
- decimal* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- decimal sum1 = 0, sum2 = 0;
- decimal* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*pc));
- sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*pc));
- pc++;
- }
-
- result += (decimal)((decimal)(*pr++) * sum1);
- result += (decimal)((decimal)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (decimal* a = matrix)
+ fixed (decimal* c = columnVector)
+ {
+ decimal* pa1 = a;
+ decimal* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- decimal sum = 0;
- decimal* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ decimal sum1 = 0, sum2 = 0;
+ decimal* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*pc));
+ sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*pc));
+ pc++;
+ }
+
+ result += (decimal)((decimal)(*pr++) * sum1);
+ result += (decimal)((decimal)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (decimal)((decimal)(*pa1++) * (decimal)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ decimal sum = 0;
+ decimal* pc = c;
- result += (decimal)((decimal)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (decimal)((decimal)(*pa1++) * (decimal)(*pc++));
+ result += (decimal)((decimal)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25327,7 +25459,7 @@ public static double DotAndDot(this decimal[] rowVector, decimal[][] matrix, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, decimal[,] matrix, double[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, decimal[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25337,48 +25469,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, decimal[,] matri
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (decimal* a = matrix)
- fixed (double* c = columnVector)
- {
- decimal* pa1 = a;
- decimal* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (decimal* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ decimal* pa1 = a;
+ decimal* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25434,7 +25569,7 @@ public static int DotAndDot(this decimal[] rowVector, decimal[][] matrix, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this decimal[] rowVector, decimal[,] matrix, int[] columnVector)
+ public static int DotAndDot(this decimal[] rowVector, decimal[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25444,48 +25579,51 @@ public static unsafe int DotAndDot(this decimal[] rowVector, decimal[,] matrix,
#endif
int result = 0;
- fixed (decimal* r = rowVector)
- fixed (decimal* a = matrix)
- fixed (int* c = columnVector)
- {
- decimal* pa1 = a;
- decimal* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (decimal* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ decimal* pa1 = a;
+ decimal* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25541,7 +25679,7 @@ public static float DotAndDot(this decimal[] rowVector, decimal[][] matrix, floa
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this decimal[] rowVector, decimal[,] matrix, float[] columnVector)
+ public static float DotAndDot(this decimal[] rowVector, decimal[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25551,48 +25689,51 @@ public static unsafe float DotAndDot(this decimal[] rowVector, decimal[,] matrix
#endif
float result = 0;
- fixed (decimal* r = rowVector)
- fixed (decimal* a = matrix)
- fixed (float* c = columnVector)
- {
- decimal* pa1 = a;
- decimal* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (decimal* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ decimal* pa1 = a;
+ decimal* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25648,7 +25789,7 @@ public static decimal DotAndDot(this decimal[] rowVector, double[][] matrix, dec
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe decimal DotAndDot(this decimal[] rowVector, double[,] matrix, decimal[] columnVector)
+ public static decimal DotAndDot(this decimal[] rowVector, double[,] matrix, decimal[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25658,48 +25799,51 @@ public static unsafe decimal DotAndDot(this decimal[] rowVector, double[,] matri
#endif
decimal result = 0;
- fixed (decimal* r = rowVector)
- fixed (double* a = matrix)
- fixed (decimal* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- decimal sum1 = 0, sum2 = 0;
- decimal* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*pc));
- sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*pc));
- pc++;
- }
-
- result += (decimal)((decimal)(*pr++) * sum1);
- result += (decimal)((decimal)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (decimal* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- decimal sum = 0;
- decimal* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ decimal sum1 = 0, sum2 = 0;
+ decimal* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*pc));
+ sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*pc));
+ pc++;
+ }
+
+ result += (decimal)((decimal)(*pr++) * sum1);
+ result += (decimal)((decimal)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (decimal)((decimal)(*pa1++) * (decimal)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ decimal sum = 0;
+ decimal* pc = c;
- result += (decimal)((decimal)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (decimal)((decimal)(*pa1++) * (decimal)(*pc++));
+ result += (decimal)((decimal)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25755,7 +25899,7 @@ public static double DotAndDot(this decimal[] rowVector, double[][] matrix, doub
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, double[,] matrix, double[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25765,48 +25909,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, double[,] matrix
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25862,7 +26009,7 @@ public static int DotAndDot(this decimal[] rowVector, double[][] matrix, int[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this decimal[] rowVector, double[,] matrix, int[] columnVector)
+ public static int DotAndDot(this decimal[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25872,48 +26019,51 @@ public static unsafe int DotAndDot(this decimal[] rowVector, double[,] matrix, i
#endif
int result = 0;
- fixed (decimal* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -25969,7 +26119,7 @@ public static float DotAndDot(this decimal[] rowVector, double[][] matrix, float
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this decimal[] rowVector, double[,] matrix, float[] columnVector)
+ public static float DotAndDot(this decimal[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -25979,48 +26129,51 @@ public static unsafe float DotAndDot(this decimal[] rowVector, double[,] matrix,
#endif
float result = 0;
- fixed (decimal* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26076,7 +26229,7 @@ public static decimal DotAndDot(this decimal[] rowVector, int[][] matrix, decima
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe decimal DotAndDot(this decimal[] rowVector, int[,] matrix, decimal[] columnVector)
+ public static decimal DotAndDot(this decimal[] rowVector, int[,] matrix, decimal[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26086,48 +26239,51 @@ public static unsafe decimal DotAndDot(this decimal[] rowVector, int[,] matrix,
#endif
decimal result = 0;
- fixed (decimal* r = rowVector)
- fixed (int* a = matrix)
- fixed (decimal* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- decimal sum1 = 0, sum2 = 0;
- decimal* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*pc));
- sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*pc));
- pc++;
- }
-
- result += (decimal)((decimal)(*pr++) * sum1);
- result += (decimal)((decimal)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (decimal* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- decimal sum = 0;
- decimal* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ decimal sum1 = 0, sum2 = 0;
+ decimal* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*pc));
+ sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*pc));
+ pc++;
+ }
+
+ result += (decimal)((decimal)(*pr++) * sum1);
+ result += (decimal)((decimal)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (decimal)((decimal)(*pa1++) * (decimal)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ decimal sum = 0;
+ decimal* pc = c;
- result += (decimal)((decimal)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (decimal)((decimal)(*pa1++) * (decimal)(*pc++));
+ result += (decimal)((decimal)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26183,7 +26339,7 @@ public static int DotAndDot(this decimal[] rowVector, int[][] matrix, int[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this decimal[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this decimal[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26193,48 +26349,51 @@ public static unsafe int DotAndDot(this decimal[] rowVector, int[,] matrix, int[
#endif
int result = 0;
- fixed (decimal* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26290,7 +26449,7 @@ public static double DotAndDot(this decimal[] rowVector, int[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26300,48 +26459,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, int[,] matrix, d
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26397,7 +26559,7 @@ public static float DotAndDot(this decimal[] rowVector, int[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this decimal[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this decimal[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26407,48 +26569,51 @@ public static unsafe float DotAndDot(this decimal[] rowVector, int[,] matrix, fl
#endif
float result = 0;
- fixed (decimal* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26504,7 +26669,7 @@ public static double DotAndDot(this decimal[] rowVector, float[][] matrix, decim
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix, decimal[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, float[,] matrix, decimal[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26514,48 +26679,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (float* a = matrix)
- fixed (decimal* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- decimal* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (decimal* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- decimal* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ decimal* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ decimal* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26611,7 +26779,7 @@ public static double DotAndDot(this decimal[] rowVector, float[][] matrix, float
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26621,48 +26789,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26718,7 +26889,7 @@ public static double DotAndDot(this decimal[] rowVector, float[][] matrix, doubl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26728,48 +26899,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26825,7 +26999,7 @@ public static double DotAndDot(this decimal[] rowVector, float[][] matrix, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this decimal[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26835,48 +27009,51 @@ public static unsafe double DotAndDot(this decimal[] rowVector, float[,] matrix,
#endif
double result = 0;
- fixed (decimal* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (decimal* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ decimal* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -26932,7 +27109,7 @@ public static byte DotAndDot(this byte[] rowVector, byte[][] matrix, byte[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe byte DotAndDot(this byte[] rowVector, byte[,] matrix, byte[] columnVector)
+ public static byte DotAndDot(this byte[] rowVector, byte[,] matrix, byte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -26942,48 +27119,51 @@ public static unsafe byte DotAndDot(this byte[] rowVector, byte[,] matrix, byte[
#endif
byte result = 0;
- fixed (byte* r = rowVector)
- fixed (byte* a = matrix)
- fixed (byte* c = columnVector)
- {
- byte* pa1 = a;
- byte* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- byte sum1 = 0, sum2 = 0;
- byte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (byte)((byte)(*pa1++) * (byte)(*pc));
- sum2 += (byte)((byte)(*pa2++) * (byte)(*pc));
- pc++;
- }
-
- result += (byte)((byte)(*pr++) * sum1);
- result += (byte)((byte)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (byte* a = matrix)
+ fixed (byte* c = columnVector)
+ {
+ byte* pa1 = a;
+ byte* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- byte sum = 0;
- byte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ byte sum1 = 0, sum2 = 0;
+ byte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (byte)((byte)(*pa1++) * (byte)(*pc));
+ sum2 += (byte)((byte)(*pa2++) * (byte)(*pc));
+ pc++;
+ }
+
+ result += (byte)((byte)(*pr++) * sum1);
+ result += (byte)((byte)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (byte)((byte)(*pa1++) * (byte)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ byte sum = 0;
+ byte* pc = c;
- result += (byte)((byte)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (byte)((byte)(*pa1++) * (byte)(*pc++));
+ result += (byte)((byte)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27039,7 +27219,7 @@ public static double DotAndDot(this byte[] rowVector, byte[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, byte[,] matrix, double[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, byte[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27049,48 +27229,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, byte[,] matrix, dou
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (byte* a = matrix)
- fixed (double* c = columnVector)
- {
- byte* pa1 = a;
- byte* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (byte* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ byte* pa1 = a;
+ byte* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27146,7 +27329,7 @@ public static int DotAndDot(this byte[] rowVector, byte[][] matrix, int[] column
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this byte[] rowVector, byte[,] matrix, int[] columnVector)
+ public static int DotAndDot(this byte[] rowVector, byte[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27156,48 +27339,51 @@ public static unsafe int DotAndDot(this byte[] rowVector, byte[,] matrix, int[]
#endif
int result = 0;
- fixed (byte* r = rowVector)
- fixed (byte* a = matrix)
- fixed (int* c = columnVector)
- {
- byte* pa1 = a;
- byte* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (byte* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ byte* pa1 = a;
+ byte* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27253,7 +27439,7 @@ public static float DotAndDot(this byte[] rowVector, byte[][] matrix, float[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this byte[] rowVector, byte[,] matrix, float[] columnVector)
+ public static float DotAndDot(this byte[] rowVector, byte[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27263,48 +27449,51 @@ public static unsafe float DotAndDot(this byte[] rowVector, byte[,] matrix, floa
#endif
float result = 0;
- fixed (byte* r = rowVector)
- fixed (byte* a = matrix)
- fixed (float* c = columnVector)
- {
- byte* pa1 = a;
- byte* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (byte* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ byte* pa1 = a;
+ byte* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27360,7 +27549,7 @@ public static byte DotAndDot(this byte[] rowVector, double[][] matrix, byte[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe byte DotAndDot(this byte[] rowVector, double[,] matrix, byte[] columnVector)
+ public static byte DotAndDot(this byte[] rowVector, double[,] matrix, byte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27370,48 +27559,51 @@ public static unsafe byte DotAndDot(this byte[] rowVector, double[,] matrix, byt
#endif
byte result = 0;
- fixed (byte* r = rowVector)
- fixed (double* a = matrix)
- fixed (byte* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- byte sum1 = 0, sum2 = 0;
- byte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (byte)((byte)(*pa1++) * (byte)(*pc));
- sum2 += (byte)((byte)(*pa2++) * (byte)(*pc));
- pc++;
- }
-
- result += (byte)((byte)(*pr++) * sum1);
- result += (byte)((byte)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (byte* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- byte sum = 0;
- byte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ byte sum1 = 0, sum2 = 0;
+ byte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (byte)((byte)(*pa1++) * (byte)(*pc));
+ sum2 += (byte)((byte)(*pa2++) * (byte)(*pc));
+ pc++;
+ }
+
+ result += (byte)((byte)(*pr++) * sum1);
+ result += (byte)((byte)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (byte)((byte)(*pa1++) * (byte)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ byte sum = 0;
+ byte* pc = c;
- result += (byte)((byte)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (byte)((byte)(*pa1++) * (byte)(*pc++));
+ result += (byte)((byte)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27467,7 +27659,7 @@ public static double DotAndDot(this byte[] rowVector, double[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, double[,] matrix, double[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27477,48 +27669,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, double[,] matrix, d
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ byte* pr = r;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27574,7 +27769,7 @@ public static int DotAndDot(this byte[] rowVector, double[][] matrix, int[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this byte[] rowVector, double[,] matrix, int[] columnVector)
+ public static int DotAndDot(this byte[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27584,48 +27779,51 @@ public static unsafe int DotAndDot(this byte[] rowVector, double[,] matrix, int[
#endif
int result = 0;
- fixed (byte* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27681,7 +27879,7 @@ public static float DotAndDot(this byte[] rowVector, double[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this byte[] rowVector, double[,] matrix, float[] columnVector)
+ public static float DotAndDot(this byte[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27691,48 +27889,51 @@ public static unsafe float DotAndDot(this byte[] rowVector, double[,] matrix, fl
#endif
float result = 0;
- fixed (byte* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27788,7 +27989,7 @@ public static byte DotAndDot(this byte[] rowVector, int[][] matrix, byte[] colum
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe byte DotAndDot(this byte[] rowVector, int[,] matrix, byte[] columnVector)
+ public static byte DotAndDot(this byte[] rowVector, int[,] matrix, byte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27798,48 +27999,51 @@ public static unsafe byte DotAndDot(this byte[] rowVector, int[,] matrix, byte[]
#endif
byte result = 0;
- fixed (byte* r = rowVector)
- fixed (int* a = matrix)
- fixed (byte* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- byte sum1 = 0, sum2 = 0;
- byte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (byte)((byte)(*pa1++) * (byte)(*pc));
- sum2 += (byte)((byte)(*pa2++) * (byte)(*pc));
- pc++;
- }
-
- result += (byte)((byte)(*pr++) * sum1);
- result += (byte)((byte)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (byte* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- byte sum = 0;
- byte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ byte sum1 = 0, sum2 = 0;
+ byte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (byte)((byte)(*pa1++) * (byte)(*pc));
+ sum2 += (byte)((byte)(*pa2++) * (byte)(*pc));
+ pc++;
+ }
+
+ result += (byte)((byte)(*pr++) * sum1);
+ result += (byte)((byte)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (byte)((byte)(*pa1++) * (byte)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ byte sum = 0;
+ byte* pc = c;
- result += (byte)((byte)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (byte)((byte)(*pa1++) * (byte)(*pc++));
+ result += (byte)((byte)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -27895,7 +28099,7 @@ public static int DotAndDot(this byte[] rowVector, int[][] matrix, int[] columnV
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this byte[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this byte[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -27905,48 +28109,51 @@ public static unsafe int DotAndDot(this byte[] rowVector, int[,] matrix, int[] c
#endif
int result = 0;
- fixed (byte* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28002,7 +28209,7 @@ public static double DotAndDot(this byte[] rowVector, int[][] matrix, double[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28012,48 +28219,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, int[,] matrix, doub
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28109,7 +28319,7 @@ public static float DotAndDot(this byte[] rowVector, int[][] matrix, float[] col
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this byte[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this byte[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28119,48 +28329,51 @@ public static unsafe float DotAndDot(this byte[] rowVector, int[,] matrix, float
#endif
float result = 0;
- fixed (byte* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28216,7 +28429,7 @@ public static double DotAndDot(this byte[] rowVector, float[][] matrix, byte[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, byte[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, float[,] matrix, byte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28226,48 +28439,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, by
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (float* a = matrix)
- fixed (byte* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- byte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (byte* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- byte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ byte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ byte* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28323,7 +28539,7 @@ public static double DotAndDot(this byte[] rowVector, float[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28333,48 +28549,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, fl
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28430,7 +28649,7 @@ public static double DotAndDot(this byte[] rowVector, float[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28440,48 +28659,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, do
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28537,7 +28759,7 @@ public static double DotAndDot(this byte[] rowVector, float[][] matrix, int[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this byte[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28547,48 +28769,51 @@ public static unsafe double DotAndDot(this byte[] rowVector, float[,] matrix, in
#endif
double result = 0;
- fixed (byte* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- byte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (byte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ byte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28644,7 +28869,7 @@ public static short DotAndDot(this short[] rowVector, short[][] matrix, short[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe short DotAndDot(this short[] rowVector, short[,] matrix, short[] columnVector)
+ public static short DotAndDot(this short[] rowVector, short[,] matrix, short[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28654,48 +28879,51 @@ public static unsafe short DotAndDot(this short[] rowVector, short[,] matrix, sh
#endif
short result = 0;
- fixed (short* r = rowVector)
- fixed (short* a = matrix)
- fixed (short* c = columnVector)
- {
- short* pa1 = a;
- short* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- short sum1 = 0, sum2 = 0;
- short* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (short)((short)(*pa1++) * (short)(*pc));
- sum2 += (short)((short)(*pa2++) * (short)(*pc));
- pc++;
- }
-
- result += (short)((short)(*pr++) * sum1);
- result += (short)((short)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (short* a = matrix)
+ fixed (short* c = columnVector)
+ {
+ short* pa1 = a;
+ short* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- short sum = 0;
- short* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ short sum1 = 0, sum2 = 0;
+ short* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (short)((short)(*pa1++) * (short)(*pc));
+ sum2 += (short)((short)(*pa2++) * (short)(*pc));
+ pc++;
+ }
+
+ result += (short)((short)(*pr++) * sum1);
+ result += (short)((short)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (short)((short)(*pa1++) * (short)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ short sum = 0;
+ short* pc = c;
- result += (short)((short)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (short)((short)(*pa1++) * (short)(*pc++));
+ result += (short)((short)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28751,7 +28979,7 @@ public static double DotAndDot(this short[] rowVector, short[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this short[] rowVector, short[,] matrix, double[] columnVector)
+ public static double DotAndDot(this short[] rowVector, short[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28761,48 +28989,51 @@ public static unsafe double DotAndDot(this short[] rowVector, short[,] matrix, d
#endif
double result = 0;
- fixed (short* r = rowVector)
- fixed (short* a = matrix)
- fixed (double* c = columnVector)
- {
- short* pa1 = a;
- short* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (short* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ short* pa1 = a;
+ short* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28858,7 +29089,7 @@ public static int DotAndDot(this short[] rowVector, short[][] matrix, int[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this short[] rowVector, short[,] matrix, int[] columnVector)
+ public static int DotAndDot(this short[] rowVector, short[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28868,48 +29099,51 @@ public static unsafe int DotAndDot(this short[] rowVector, short[,] matrix, int[
#endif
int result = 0;
- fixed (short* r = rowVector)
- fixed (short* a = matrix)
- fixed (int* c = columnVector)
- {
- short* pa1 = a;
- short* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (short* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ short* pa1 = a;
+ short* pa2 = a + cols;
+ short* pr = r;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
-
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -28965,7 +29199,7 @@ public static float DotAndDot(this short[] rowVector, short[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this short[] rowVector, short[,] matrix, float[] columnVector)
+ public static float DotAndDot(this short[] rowVector, short[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -28975,48 +29209,51 @@ public static unsafe float DotAndDot(this short[] rowVector, short[,] matrix, fl
#endif
float result = 0;
- fixed (short* r = rowVector)
- fixed (short* a = matrix)
- fixed (float* c = columnVector)
- {
- short* pa1 = a;
- short* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (short* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ short* pa1 = a;
+ short* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29072,7 +29309,7 @@ public static short DotAndDot(this short[] rowVector, double[][] matrix, short[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe short DotAndDot(this short[] rowVector, double[,] matrix, short[] columnVector)
+ public static short DotAndDot(this short[] rowVector, double[,] matrix, short[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29082,48 +29319,51 @@ public static unsafe short DotAndDot(this short[] rowVector, double[,] matrix, s
#endif
short result = 0;
- fixed (short* r = rowVector)
- fixed (double* a = matrix)
- fixed (short* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- short sum1 = 0, sum2 = 0;
- short* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (short)((short)(*pa1++) * (short)(*pc));
- sum2 += (short)((short)(*pa2++) * (short)(*pc));
- pc++;
- }
-
- result += (short)((short)(*pr++) * sum1);
- result += (short)((short)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (short* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- short sum = 0;
- short* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ short sum1 = 0, sum2 = 0;
+ short* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (short)((short)(*pa1++) * (short)(*pc));
+ sum2 += (short)((short)(*pa2++) * (short)(*pc));
+ pc++;
+ }
+
+ result += (short)((short)(*pr++) * sum1);
+ result += (short)((short)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (short)((short)(*pa1++) * (short)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ short sum = 0;
+ short* pc = c;
- result += (short)((short)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (short)((short)(*pa1++) * (short)(*pc++));
+ result += (short)((short)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29179,7 +29419,7 @@ public static double DotAndDot(this short[] rowVector, double[][] matrix, double
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this short[] rowVector, double[,] matrix, double[] columnVector)
+ public static double DotAndDot(this short[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29189,48 +29429,51 @@ public static unsafe double DotAndDot(this short[] rowVector, double[,] matrix,
#endif
double result = 0;
- fixed (short* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29286,7 +29529,7 @@ public static int DotAndDot(this short[] rowVector, double[][] matrix, int[] col
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this short[] rowVector, double[,] matrix, int[] columnVector)
+ public static int DotAndDot(this short[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29296,48 +29539,51 @@ public static unsafe int DotAndDot(this short[] rowVector, double[,] matrix, int
#endif
int result = 0;
- fixed (short* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29393,7 +29639,7 @@ public static float DotAndDot(this short[] rowVector, double[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this short[] rowVector, double[,] matrix, float[] columnVector)
+ public static float DotAndDot(this short[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29403,48 +29649,51 @@ public static unsafe float DotAndDot(this short[] rowVector, double[,] matrix, f
#endif
float result = 0;
- fixed (short* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29500,7 +29749,7 @@ public static short DotAndDot(this short[] rowVector, int[][] matrix, short[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe short DotAndDot(this short[] rowVector, int[,] matrix, short[] columnVector)
+ public static short DotAndDot(this short[] rowVector, int[,] matrix, short[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29510,48 +29759,51 @@ public static unsafe short DotAndDot(this short[] rowVector, int[,] matrix, shor
#endif
short result = 0;
- fixed (short* r = rowVector)
- fixed (int* a = matrix)
- fixed (short* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- short sum1 = 0, sum2 = 0;
- short* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (short)((short)(*pa1++) * (short)(*pc));
- sum2 += (short)((short)(*pa2++) * (short)(*pc));
- pc++;
- }
-
- result += (short)((short)(*pr++) * sum1);
- result += (short)((short)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (short* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- short sum = 0;
- short* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ short sum1 = 0, sum2 = 0;
+ short* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (short)((short)(*pa1++) * (short)(*pc));
+ sum2 += (short)((short)(*pa2++) * (short)(*pc));
+ pc++;
+ }
+
+ result += (short)((short)(*pr++) * sum1);
+ result += (short)((short)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (short)((short)(*pa1++) * (short)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ short sum = 0;
+ short* pc = c;
- result += (short)((short)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (short)((short)(*pa1++) * (short)(*pc++));
+ result += (short)((short)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29607,7 +29859,7 @@ public static int DotAndDot(this short[] rowVector, int[][] matrix, int[] column
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this short[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this short[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29617,48 +29869,51 @@ public static unsafe int DotAndDot(this short[] rowVector, int[,] matrix, int[]
#endif
int result = 0;
- fixed (short* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29714,7 +29969,7 @@ public static double DotAndDot(this short[] rowVector, int[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this short[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this short[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29724,48 +29979,51 @@ public static unsafe double DotAndDot(this short[] rowVector, int[,] matrix, dou
#endif
double result = 0;
- fixed (short* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29821,7 +30079,7 @@ public static float DotAndDot(this short[] rowVector, int[][] matrix, float[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this short[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this short[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29831,48 +30089,51 @@ public static unsafe float DotAndDot(this short[] rowVector, int[,] matrix, floa
#endif
float result = 0;
- fixed (short* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -29928,7 +30189,7 @@ public static double DotAndDot(this short[] rowVector, float[][] matrix, short[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, short[] columnVector)
+ public static double DotAndDot(this short[] rowVector, float[,] matrix, short[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -29938,48 +30199,51 @@ public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, s
#endif
double result = 0;
- fixed (short* r = rowVector)
- fixed (float* a = matrix)
- fixed (short* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- short* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (short* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- short* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ short* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ short* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30035,7 +30299,7 @@ public static double DotAndDot(this short[] rowVector, float[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this short[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30045,48 +30309,51 @@ public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, f
#endif
double result = 0;
- fixed (short* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30142,7 +30409,7 @@ public static double DotAndDot(this short[] rowVector, float[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this short[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30152,155 +30419,51 @@ public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, d
#endif
double result = 0;
- fixed (short* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
-
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
-
- return result;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ short* pr = r;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
- ///
- /// Computes the product a*B*c of a row vector a,
- /// a square matrix B and a column vector c.
- ///
- ///
- /// The left vector a.
- /// The square matrix B.
- /// The column vector c.
- ///
- /// The product a*B*c of the given vector a,
- /// matrix B and vector c.
- ///
-#if NET45 || NET46 || NET462 || NETSTANDARD
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
-#endif
- public static double DotAndDot(this short[] rowVector, float[][] matrix, int[] columnVector)
- {
-#if DEBUG
- if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
- throw new DimensionMismatchException();
-#endif
- double sum = 0;
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
- for (int i = 0; i < rowVector.Length; i++)
- {
- double s = 0;
- for (int j = 0; j < columnVector.Length; j++)
- s += (double)((double)matrix[i][j] * (double)columnVector[j]);
- sum += (double)((double)rowVector[i] * (double)s);
- }
-
- return sum;
- }
-
- ///
- /// Computes the product a*B*c of a row vector a,
- /// a square matrix B and a column vector c.
- ///
- ///
- /// The left vector a.
- /// The square matrix B.
- /// The column vector c.
- ///
- /// The product a*B*c of the given vector a,
- /// matrix B and vector c.
- ///
-#if NET45 || NET46 || NET462 || NETSTANDARD
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
-#endif
- public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, int[] columnVector)
- {
- int cols = matrix.Columns();
- int rows = matrix.Rows();
-#if DEBUG
- if (rowVector.Length != rows || cols != columnVector.Length)
- throw new DimensionMismatchException();
-#endif
- double result = 0;
-
- fixed (short* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- short* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
-
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
-
- result += (double)((double)(*pr++) * sum);
- }
- }
-
return result;
}
@@ -30322,20 +30485,20 @@ public static unsafe double DotAndDot(this short[] rowVector, float[,] matrix, i
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static sbyte DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, sbyte[] columnVector)
+ public static double DotAndDot(this short[] rowVector, float[][] matrix, int[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- sbyte sum = 0;
+ double sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- sbyte s = 0;
+ double s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (sbyte)((sbyte)matrix[i][j] * (sbyte)columnVector[j]);
- sum += (sbyte)((sbyte)rowVector[i] * (sbyte)s);
+ s += (double)((double)matrix[i][j] * (double)columnVector[j]);
+ sum += (double)((double)rowVector[i] * (double)s);
}
return sum;
@@ -30356,7 +30519,7 @@ public static sbyte DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, sbyte[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe sbyte DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, sbyte[] columnVector)
+ public static double DotAndDot(this short[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30364,50 +30527,53 @@ public static unsafe sbyte DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, sb
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- sbyte result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (sbyte* a = matrix)
- fixed (sbyte* c = columnVector)
- {
- sbyte* pa1 = a;
- sbyte* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- sbyte sum1 = 0, sum2 = 0;
- sbyte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc));
- sum2 += (sbyte)((sbyte)(*pa2++) * (sbyte)(*pc));
- pc++;
- }
-
- result += (sbyte)((sbyte)(*pr++) * sum1);
- result += (sbyte)((sbyte)(*pr++) * sum2);
+ double result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (short* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ short* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- sbyte sum = 0;
- sbyte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (sbyte)((sbyte)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30429,20 +30595,20 @@ public static unsafe sbyte DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, sb
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, double[] columnVector)
+ public static sbyte DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, sbyte[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double sum = 0;
+ sbyte sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- double s = 0;
+ sbyte s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (double)((double)matrix[i][j] * (double)columnVector[j]);
- sum += (double)((double)rowVector[i] * (double)s);
+ s += (sbyte)((sbyte)matrix[i][j] * (sbyte)columnVector[j]);
+ sum += (sbyte)((sbyte)rowVector[i] * (sbyte)s);
}
return sum;
@@ -30463,7 +30629,7 @@ public static double DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, double[] columnVector)
+ public static sbyte DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, sbyte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30471,50 +30637,53 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, d
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (sbyte* a = matrix)
- fixed (double* c = columnVector)
- {
- sbyte* pa1 = a;
- sbyte* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ sbyte result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (sbyte* a = matrix)
+ fixed (sbyte* c = columnVector)
+ {
+ sbyte* pa1 = a;
+ sbyte* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ sbyte sum1 = 0, sum2 = 0;
+ sbyte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc));
+ sum2 += (sbyte)((sbyte)(*pa2++) * (sbyte)(*pc));
+ pc++;
+ }
+
+ result += (sbyte)((sbyte)(*pr++) * sum1);
+ result += (sbyte)((sbyte)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ sbyte sum = 0;
+ sbyte* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc++));
+ result += (sbyte)((sbyte)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30536,20 +30705,20 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static int DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, int[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, double[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- int sum = 0;
+ double sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- int s = 0;
+ double s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (int)((int)matrix[i][j] * (int)columnVector[j]);
- sum += (int)((int)rowVector[i] * (int)s);
+ s += (double)((double)matrix[i][j] * (double)columnVector[j]);
+ sum += (double)((double)rowVector[i] * (double)s);
}
return sum;
@@ -30570,7 +30739,7 @@ public static int DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, int[] colu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, int[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30578,50 +30747,53 @@ public static unsafe int DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, int[
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- int result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (sbyte* a = matrix)
- fixed (int* c = columnVector)
- {
- sbyte* pa1 = a;
- sbyte* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
+ double result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (sbyte* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ sbyte* pa1 = a;
+ sbyte* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30643,20 +30815,20 @@ public static unsafe int DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static float DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, float[] columnVector)
+ public static int DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, int[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- float sum = 0;
+ int sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- float s = 0;
+ int s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (float)((float)matrix[i][j] * (float)columnVector[j]);
- sum += (float)((float)rowVector[i] * (float)s);
+ s += (int)((int)matrix[i][j] * (int)columnVector[j]);
+ sum += (int)((int)rowVector[i] * (int)s);
}
return sum;
@@ -30677,7 +30849,7 @@ public static float DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, float[] columnVector)
+ public static int DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30685,50 +30857,53 @@ public static unsafe float DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, fl
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- float result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (sbyte* a = matrix)
- fixed (float* c = columnVector)
- {
- sbyte* pa1 = a;
- sbyte* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
+ int result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (sbyte* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ sbyte* pa1 = a;
+ sbyte* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30750,20 +30925,20 @@ public static unsafe float DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, fl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static sbyte DotAndDot(this sbyte[] rowVector, double[][] matrix, sbyte[] columnVector)
+ public static float DotAndDot(this sbyte[] rowVector, sbyte[][] matrix, float[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- sbyte sum = 0;
+ float sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- sbyte s = 0;
+ float s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (sbyte)((sbyte)matrix[i][j] * (sbyte)columnVector[j]);
- sum += (sbyte)((sbyte)rowVector[i] * (sbyte)s);
+ s += (float)((float)matrix[i][j] * (float)columnVector[j]);
+ sum += (float)((float)rowVector[i] * (float)s);
}
return sum;
@@ -30784,7 +30959,7 @@ public static sbyte DotAndDot(this sbyte[] rowVector, double[][] matrix, sbyte[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe sbyte DotAndDot(this sbyte[] rowVector, double[,] matrix, sbyte[] columnVector)
+ public static float DotAndDot(this sbyte[] rowVector, sbyte[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30792,50 +30967,53 @@ public static unsafe sbyte DotAndDot(this sbyte[] rowVector, double[,] matrix, s
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- sbyte result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (double* a = matrix)
- fixed (sbyte* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- sbyte sum1 = 0, sum2 = 0;
- sbyte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc));
- sum2 += (sbyte)((sbyte)(*pa2++) * (sbyte)(*pc));
- pc++;
- }
-
- result += (sbyte)((sbyte)(*pr++) * sum1);
- result += (sbyte)((sbyte)(*pr++) * sum2);
+ float result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (sbyte* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ sbyte* pa1 = a;
+ sbyte* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- sbyte sum = 0;
- sbyte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (sbyte)((sbyte)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30857,20 +31035,20 @@ public static unsafe sbyte DotAndDot(this sbyte[] rowVector, double[,] matrix, s
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static double DotAndDot(this sbyte[] rowVector, double[][] matrix, double[] columnVector)
+ public static sbyte DotAndDot(this sbyte[] rowVector, double[][] matrix, sbyte[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double sum = 0;
+ sbyte sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- double s = 0;
+ sbyte s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (double)((double)matrix[i][j] * (double)columnVector[j]);
- sum += (double)((double)rowVector[i] * (double)s);
+ s += (sbyte)((sbyte)matrix[i][j] * (sbyte)columnVector[j]);
+ sum += (sbyte)((sbyte)rowVector[i] * (sbyte)s);
}
return sum;
@@ -30891,7 +31069,7 @@ public static double DotAndDot(this sbyte[] rowVector, double[][] matrix, double
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, double[,] matrix, double[] columnVector)
+ public static sbyte DotAndDot(this sbyte[] rowVector, double[,] matrix, sbyte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -30899,50 +31077,53 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, double[,] matrix,
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- double result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (double* a = matrix)
- fixed (double* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
+ sbyte result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (sbyte* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ sbyte sum1 = 0, sum2 = 0;
+ sbyte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc));
+ sum2 += (sbyte)((sbyte)(*pa2++) * (sbyte)(*pc));
+ pc++;
+ }
+
+ result += (sbyte)((sbyte)(*pr++) * sum1);
+ result += (sbyte)((sbyte)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ sbyte sum = 0;
+ sbyte* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc++));
+ result += (sbyte)((sbyte)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -30964,20 +31145,20 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, double[,] matrix,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static int DotAndDot(this sbyte[] rowVector, double[][] matrix, int[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, double[][] matrix, double[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- int sum = 0;
+ double sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- int s = 0;
+ double s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (int)((int)matrix[i][j] * (int)columnVector[j]);
- sum += (int)((int)rowVector[i] * (int)s);
+ s += (double)((double)matrix[i][j] * (double)columnVector[j]);
+ sum += (double)((double)rowVector[i] * (double)s);
}
return sum;
@@ -30998,7 +31179,7 @@ public static int DotAndDot(this sbyte[] rowVector, double[][] matrix, int[] col
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this sbyte[] rowVector, double[,] matrix, int[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, double[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31006,50 +31187,53 @@ public static unsafe int DotAndDot(this sbyte[] rowVector, double[,] matrix, int
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- int result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (double* a = matrix)
- fixed (int* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
+ double result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31071,20 +31255,20 @@ public static unsafe int DotAndDot(this sbyte[] rowVector, double[,] matrix, int
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static float DotAndDot(this sbyte[] rowVector, double[][] matrix, float[] columnVector)
+ public static int DotAndDot(this sbyte[] rowVector, double[][] matrix, int[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- float sum = 0;
+ int sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- float s = 0;
+ int s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (float)((float)matrix[i][j] * (float)columnVector[j]);
- sum += (float)((float)rowVector[i] * (float)s);
+ s += (int)((int)matrix[i][j] * (int)columnVector[j]);
+ sum += (int)((int)rowVector[i] * (int)s);
}
return sum;
@@ -31105,7 +31289,7 @@ public static float DotAndDot(this sbyte[] rowVector, double[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this sbyte[] rowVector, double[,] matrix, float[] columnVector)
+ public static int DotAndDot(this sbyte[] rowVector, double[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31113,50 +31297,53 @@ public static unsafe float DotAndDot(this sbyte[] rowVector, double[,] matrix, f
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- float result = 0;
-
- fixed (sbyte* r = rowVector)
- fixed (double* a = matrix)
- fixed (float* c = columnVector)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
+ int result = 0;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31178,20 +31365,20 @@ public static unsafe float DotAndDot(this sbyte[] rowVector, double[,] matrix, f
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static sbyte DotAndDot(this sbyte[] rowVector, int[][] matrix, sbyte[] columnVector)
+ public static float DotAndDot(this sbyte[] rowVector, double[][] matrix, float[] columnVector)
{
#if DEBUG
if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
throw new DimensionMismatchException();
#endif
- sbyte sum = 0;
+ float sum = 0;
for (int i = 0; i < rowVector.Length; i++)
{
- sbyte s = 0;
+ float s = 0;
for (int j = 0; j < columnVector.Length; j++)
- s += (sbyte)((sbyte)matrix[i][j] * (sbyte)columnVector[j]);
- sum += (sbyte)((sbyte)rowVector[i] * (sbyte)s);
+ s += (float)((float)matrix[i][j] * (float)columnVector[j]);
+ sum += (float)((float)rowVector[i] * (float)s);
}
return sum;
@@ -31212,7 +31399,7 @@ public static sbyte DotAndDot(this sbyte[] rowVector, int[][] matrix, sbyte[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe sbyte DotAndDot(this sbyte[] rowVector, int[,] matrix, sbyte[] columnVector)
+ public static float DotAndDot(this sbyte[] rowVector, double[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31220,50 +31407,163 @@ public static unsafe sbyte DotAndDot(this sbyte[] rowVector, int[,] matrix, sbyt
if (rowVector.Length != rows || cols != columnVector.Length)
throw new DimensionMismatchException();
#endif
- sbyte result = 0;
+ float result = 0;
- fixed (sbyte* r = rowVector)
- fixed (int* a = matrix)
- fixed (sbyte* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- sbyte* pr = r;
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (double* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ sbyte* pr = r;
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- sbyte sum1 = 0, sum2 = 0;
- sbyte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- {
- sum1 += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc));
- sum2 += (sbyte)((sbyte)(*pa2++) * (sbyte)(*pc));
- pc++;
- }
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (sbyte)((sbyte)(*pr++) * sum1);
- result += (sbyte)((sbyte)(*pr++) * sum2);
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
+ return result;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- sbyte sum = 0;
- sbyte* pc = c;
- for (int j = 0; j < cols; j++)
- sum += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc++));
- result += (sbyte)((sbyte)(*pr++) * sum);
- }
+
+ ///
+ /// Computes the product a*B*c of a row vector a,
+ /// a square matrix B and a column vector c.
+ ///
+ ///
+ /// The left vector a.
+ /// The square matrix B.
+ /// The column vector c.
+ ///
+ /// The product a*B*c of the given vector a,
+ /// matrix B and vector c.
+ ///
+#if NET45 || NET46 || NET462 || NETSTANDARD
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#endif
+ public static sbyte DotAndDot(this sbyte[] rowVector, int[][] matrix, sbyte[] columnVector)
+ {
+#if DEBUG
+ if (rowVector.Length != matrix.Rows() || matrix.Columns() != columnVector.Length)
+ throw new DimensionMismatchException();
+#endif
+ sbyte sum = 0;
+
+ for (int i = 0; i < rowVector.Length; i++)
+ {
+ sbyte s = 0;
+ for (int j = 0; j < columnVector.Length; j++)
+ s += (sbyte)((sbyte)matrix[i][j] * (sbyte)columnVector[j]);
+ sum += (sbyte)((sbyte)rowVector[i] * (sbyte)s);
}
+ return sum;
+ }
+
+ ///
+ /// Computes the product a*B*c of a row vector a,
+ /// a square matrix B and a column vector c.
+ ///
+ ///
+ /// The left vector a.
+ /// The square matrix B.
+ /// The column vector c.
+ ///
+ /// The product a*B*c of the given vector a,
+ /// matrix B and vector c.
+ ///
+#if NET45 || NET46 || NET462 || NETSTANDARD
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#endif
+ public static sbyte DotAndDot(this sbyte[] rowVector, int[,] matrix, sbyte[] columnVector)
+ {
+ int cols = matrix.Columns();
+ int rows = matrix.Rows();
+#if DEBUG
+ if (rowVector.Length != rows || cols != columnVector.Length)
+ throw new DimensionMismatchException();
+#endif
+ sbyte result = 0;
+
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (sbyte* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ sbyte* pr = r;
+
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ sbyte sum1 = 0, sum2 = 0;
+ sbyte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc));
+ sum2 += (sbyte)((sbyte)(*pa2++) * (sbyte)(*pc));
+ pc++;
+ }
+
+ result += (sbyte)((sbyte)(*pr++) * sum1);
+ result += (sbyte)((sbyte)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
+
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ sbyte sum = 0;
+ sbyte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ sum += (sbyte)((sbyte)(*pa1++) * (sbyte)(*pc++));
+
+ result += (sbyte)((sbyte)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31319,7 +31619,7 @@ public static int DotAndDot(this sbyte[] rowVector, int[][] matrix, int[] column
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int DotAndDot(this sbyte[] rowVector, int[,] matrix, int[] columnVector)
+ public static int DotAndDot(this sbyte[] rowVector, int[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31329,48 +31629,51 @@ public static unsafe int DotAndDot(this sbyte[] rowVector, int[,] matrix, int[]
#endif
int result = 0;
- fixed (sbyte* r = rowVector)
- fixed (int* a = matrix)
- fixed (int* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*pc));
- sum2 += (int)((int)(*pa2++) * (int)(*pc));
- pc++;
- }
-
- result += (int)((int)(*pr++) * sum1);
- result += (int)((int)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*pc));
+ sum2 += (int)((int)(*pa2++) * (int)(*pc));
+ pc++;
+ }
+
+ result += (int)((int)(*pr++) * sum1);
+ result += (int)((int)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* pc = c;
- result += (int)((int)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*pc++));
+ result += (int)((int)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31426,7 +31729,7 @@ public static double DotAndDot(this sbyte[] rowVector, int[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, int[,] matrix, double[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, int[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31436,48 +31739,51 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, int[,] matrix, dou
#endif
double result = 0;
- fixed (sbyte* r = rowVector)
- fixed (int* a = matrix)
- fixed (double* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31533,7 +31839,7 @@ public static float DotAndDot(this sbyte[] rowVector, int[][] matrix, float[] co
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float DotAndDot(this sbyte[] rowVector, int[,] matrix, float[] columnVector)
+ public static float DotAndDot(this sbyte[] rowVector, int[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31543,48 +31849,51 @@ public static unsafe float DotAndDot(this sbyte[] rowVector, int[,] matrix, floa
#endif
float result = 0;
- fixed (sbyte* r = rowVector)
- fixed (int* a = matrix)
- fixed (float* c = columnVector)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- float sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (float)((float)(*pa1++) * (float)(*pc));
- sum2 += (float)((float)(*pa2++) * (float)(*pc));
- pc++;
- }
-
- result += (float)((float)(*pr++) * sum1);
- result += (float)((float)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (int* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- float sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ float sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (float)((float)(*pa1++) * (float)(*pc));
+ sum2 += (float)((float)(*pa2++) * (float)(*pc));
+ pc++;
+ }
+
+ result += (float)((float)(*pr++) * sum1);
+ result += (float)((float)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (float)((float)(*pa1++) * (float)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ float sum = 0;
+ float* pc = c;
- result += (float)((float)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (float)((float)(*pa1++) * (float)(*pc++));
+ result += (float)((float)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31640,7 +31949,7 @@ public static double DotAndDot(this sbyte[] rowVector, float[][] matrix, sbyte[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, sbyte[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, float[,] matrix, sbyte[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31650,48 +31959,51 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, s
#endif
double result = 0;
- fixed (sbyte* r = rowVector)
- fixed (float* a = matrix)
- fixed (sbyte* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- sbyte* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (sbyte* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- sbyte* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ sbyte* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ sbyte* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31747,7 +32059,7 @@ public static double DotAndDot(this sbyte[] rowVector, float[][] matrix, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, float[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, float[,] matrix, float[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31757,48 +32069,51 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, f
#endif
double result = 0;
- fixed (sbyte* r = rowVector)
- fixed (float* a = matrix)
- fixed (float* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (float* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31854,7 +32169,7 @@ public static double DotAndDot(this sbyte[] rowVector, float[][] matrix, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, double[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, float[,] matrix, double[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31864,48 +32179,51 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, d
#endif
double result = 0;
- fixed (sbyte* r = rowVector)
- fixed (float* a = matrix)
- fixed (double* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (double* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -31961,7 +32279,7 @@ public static double DotAndDot(this sbyte[] rowVector, float[][] matrix, int[] c
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, int[] columnVector)
+ public static double DotAndDot(this sbyte[] rowVector, float[,] matrix, int[] columnVector)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -31971,48 +32289,51 @@ public static unsafe double DotAndDot(this sbyte[] rowVector, float[,] matrix, i
#endif
double result = 0;
- fixed (sbyte* r = rowVector)
- fixed (float* a = matrix)
- fixed (int* c = columnVector)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- sbyte* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* pc = c;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*pc));
- sum2 += (double)((double)(*pa2++) * (double)(*pc));
- pc++;
- }
-
- result += (double)((double)(*pr++) * sum1);
- result += (double)((double)(*pr++) * sum2);
-
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ unsafe
+ {
+ fixed (sbyte* r = rowVector)
+ fixed (float* a = matrix)
+ fixed (int* c = columnVector)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ sbyte* pr = r;
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* pc = c;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* pc = c;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*pc));
+ sum2 += (double)((double)(*pa2++) * (double)(*pc));
+ pc++;
+ }
+
+ result += (double)((double)(*pr++) * sum1);
+ result += (double)((double)(*pr++) * sum2);
+
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*pc++));
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* pc = c;
- result += (double)((double)(*pr++) * sum);
- }
- }
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*pc++));
+ result += (double)((double)(*pr++) * sum);
+ }
+ }
+ }
+
return result;
}
@@ -32204,7 +32525,7 @@ public static int[][] Dot(this int[][] a, int[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this int[,] a, int[][] b, int[][] result)
+ public static int[][] Dot(this int[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -32218,21 +32539,24 @@ public static unsafe int[][] Dot(this int[,] a, int[][] b, int[][] result)
var t = new int[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -32310,7 +32634,7 @@ public static int[] Dot(this int[][] matrix, int[] columnVector, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this int[,] matrix, int[] columnVector, int[] result)
+ public static int[] Dot(this int[,] matrix, int[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -32319,55 +32643,54 @@ public static unsafe int[] Dot(this int[,] matrix, int[] columnVector, int[] res
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (int* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ int* pr = r;
- fixed (int* a = matrix)
- fixed (int* x = columnVector)
- fixed (int* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -32473,7 +32796,7 @@ public static int[] Dot(this int[] rowVector, int[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this int[][] a, int[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this int[][] a, int[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -32483,19 +32806,22 @@ public static unsafe int[][] DotWithTransposed(this int[][] a, int[,] b, int[][]
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -32517,7 +32843,7 @@ public static unsafe int[][] DotWithTransposed(this int[][] a, int[,] b, int[][]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this int[,] a, int[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this int[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -32527,20 +32853,22 @@ public static unsafe int[][] DotWithTransposed(this int[,] a, int[][] b, int[][]
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -32686,7 +33014,7 @@ public static int[][] DotWithTransposed(this int[][] a, int[] columnVector, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this int[,] a, int[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this int[,] a, int[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -32697,35 +33025,37 @@ public static int[][] DotWithTransposed(this int[][] a, int[] columnVector, int[
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (int* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (int* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -33119,18 +33449,22 @@ public static int[][] DivideByDiagonal(this int[][] a, int[] diagonal, int[][] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this int[] a, int[] b, int[,] result)
+ public static int[,] Outer(this int[] a, int[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -33293,25 +33627,28 @@ public static int[][] Kronecker(this int[][] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this int[][] a, int[,] b, int[][] result)
+ public static int[][] Kronecker(this int[][] a, int[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -33365,18 +33702,22 @@ public static int[][] Kronecker(this int[,] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this int[] a, int[] b, int[] result)
+ public static int[] Kronecker(this int[] a, int[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -33570,7 +33911,7 @@ public static double[][] Dot(this int[][] a, int[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this int[,] a, int[][] b, double[][] result)
+ public static double[][] Dot(this int[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -33584,21 +33925,24 @@ public static unsafe double[][] Dot(this int[,] a, int[][] b, double[][] result)
var t = new int[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -33676,7 +34020,7 @@ public static double[] Dot(this int[][] matrix, int[] columnVector, double[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this int[,] matrix, int[] columnVector, double[] result)
+ public static double[] Dot(this int[,] matrix, int[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -33685,55 +34029,54 @@ public static unsafe double[] Dot(this int[,] matrix, int[] columnVector, double
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (double* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ double* pr = r;
- fixed (int* a = matrix)
- fixed (int* x = columnVector)
- fixed (double* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -33839,7 +34182,7 @@ public static double[] Dot(this int[] rowVector, int[][] matrix, double[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this int[][] a, int[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this int[][] a, int[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -33849,19 +34192,22 @@ public static unsafe double[][] DotWithTransposed(this int[][] a, int[,] b, doub
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -33883,7 +34229,7 @@ public static unsafe double[][] DotWithTransposed(this int[][] a, int[,] b, doub
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this int[,] a, int[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this int[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -33893,20 +34239,22 @@ public static unsafe double[][] DotWithTransposed(this int[,] a, int[][] b, doub
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -34052,7 +34400,7 @@ public static double[][] DotWithTransposed(this int[][] a, int[] columnVector, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this int[,] a, int[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this int[,] a, int[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -34063,35 +34411,37 @@ public static double[][] DotWithTransposed(this int[][] a, int[] columnVector, d
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (int* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (int* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -34485,18 +34835,22 @@ public static double[][] DivideByDiagonal(this int[][] a, int[] diagonal, double
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this int[] a, int[] b, double[,] result)
+ public static double[,] Outer(this int[] a, int[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -34659,25 +35013,28 @@ public static double[][] Kronecker(this int[][] a, int[][] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this int[][] a, int[,] b, double[][] result)
+ public static double[][] Kronecker(this int[][] a, int[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -34731,18 +35088,22 @@ public static double[][] Kronecker(this int[,] a, int[][] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this int[] a, int[] b, double[] result)
+ public static double[] Kronecker(this int[] a, int[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -34936,7 +35297,7 @@ public static int[][] Dot(this int[][] a, double[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this int[,] a, double[][] b, int[][] result)
+ public static int[][] Dot(this int[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -34950,21 +35311,24 @@ public static unsafe int[][] Dot(this int[,] a, double[][] b, int[][] result)
var t = new double[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -35042,7 +35406,7 @@ public static int[] Dot(this int[][] matrix, double[] columnVector, int[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this int[,] matrix, double[] columnVector, int[] result)
+ public static int[] Dot(this int[,] matrix, double[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -35051,55 +35415,54 @@ public static unsafe int[] Dot(this int[,] matrix, double[] columnVector, int[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (int* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ int* pr = r;
- fixed (int* a = matrix)
- fixed (double* x = columnVector)
- fixed (int* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -35205,7 +35568,7 @@ public static int[] Dot(this int[] rowVector, double[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this int[][] a, double[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this int[][] a, double[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -35215,19 +35578,22 @@ public static unsafe int[][] DotWithTransposed(this int[][] a, double[,] b, int[
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -35249,7 +35615,7 @@ public static unsafe int[][] DotWithTransposed(this int[][] a, double[,] b, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this int[,] a, double[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this int[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -35259,20 +35625,22 @@ public static unsafe int[][] DotWithTransposed(this int[,] a, double[][] b, int[
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -35418,7 +35786,7 @@ public static int[][] DotWithTransposed(this int[][] a, double[] columnVector, i
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this int[,] a, double[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this int[,] a, double[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -35429,35 +35797,37 @@ public static int[][] DotWithTransposed(this int[][] a, double[] columnVector, i
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (double* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (double* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -35851,18 +36221,22 @@ public static int[][] DivideByDiagonal(this int[][] a, double[] diagonal, int[][
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this int[] a, double[] b, int[,] result)
+ public static int[,] Outer(this int[] a, double[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -36025,25 +36399,28 @@ public static int[][] Kronecker(this int[][] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this int[][] a, double[,] b, int[][] result)
+ public static int[][] Kronecker(this int[][] a, double[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -36097,18 +36474,22 @@ public static int[][] Kronecker(this int[,] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this int[] a, double[] b, int[] result)
+ public static int[] Kronecker(this int[] a, double[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -36302,7 +36683,7 @@ public static double[][] Dot(this int[][] a, double[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this int[,] a, double[][] b, double[][] result)
+ public static double[][] Dot(this int[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -36316,21 +36697,24 @@ public static unsafe double[][] Dot(this int[,] a, double[][] b, double[][] resu
var t = new double[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -36408,7 +36792,7 @@ public static double[] Dot(this int[][] matrix, double[] columnVector, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this int[,] matrix, double[] columnVector, double[] result)
+ public static double[] Dot(this int[,] matrix, double[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -36417,55 +36801,54 @@ public static unsafe double[] Dot(this int[,] matrix, double[] columnVector, dou
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (double* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ double* pr = r;
- fixed (int* a = matrix)
- fixed (double* x = columnVector)
- fixed (double* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -36571,7 +36954,7 @@ public static double[] Dot(this int[] rowVector, double[][] matrix, double[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this int[][] a, double[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this int[][] a, double[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -36581,19 +36964,22 @@ public static unsafe double[][] DotWithTransposed(this int[][] a, double[,] b, d
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -36615,7 +37001,7 @@ public static unsafe double[][] DotWithTransposed(this int[][] a, double[,] b, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this int[,] a, double[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this int[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -36625,20 +37011,22 @@ public static unsafe double[][] DotWithTransposed(this int[,] a, double[][] b, d
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -36784,7 +37172,7 @@ public static double[][] DotWithTransposed(this int[][] a, double[] columnVector
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this int[,] a, double[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this int[,] a, double[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -36795,35 +37183,37 @@ public static double[][] DotWithTransposed(this int[][] a, double[] columnVector
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (double* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (double* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -37217,18 +37607,22 @@ public static double[][] DivideByDiagonal(this int[][] a, double[] diagonal, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this int[] a, double[] b, double[,] result)
+ public static double[,] Outer(this int[] a, double[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -37391,25 +37785,28 @@ public static double[][] Kronecker(this int[][] a, double[][] b, double[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this int[][] a, double[,] b, double[][] result)
+ public static double[][] Kronecker(this int[][] a, double[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -37463,18 +37860,22 @@ public static double[][] Kronecker(this int[,] a, double[][] b, double[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this int[] a, double[] b, double[] result)
+ public static double[] Kronecker(this int[] a, double[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -37668,7 +38069,7 @@ public static int[][] Dot(this int[][] a, float[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this int[,] a, float[][] b, int[][] result)
+ public static int[][] Dot(this int[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -37682,21 +38083,24 @@ public static unsafe int[][] Dot(this int[,] a, float[][] b, int[][] result)
var t = new float[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (int)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -37774,7 +38178,7 @@ public static int[] Dot(this int[][] matrix, float[] columnVector, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this int[,] matrix, float[] columnVector, int[] result)
+ public static int[] Dot(this int[,] matrix, float[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -37783,55 +38187,54 @@ public static unsafe int[] Dot(this int[,] matrix, float[] columnVector, int[] r
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (int* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ int* pr = r;
- fixed (int* a = matrix)
- fixed (float* x = columnVector)
- fixed (int* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -37937,7 +38340,7 @@ public static int[] Dot(this int[] rowVector, float[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this int[][] a, float[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this int[][] a, float[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -37947,19 +38350,22 @@ public static unsafe int[][] DotWithTransposed(this int[][] a, float[,] b, int[]
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -37981,7 +38387,7 @@ public static unsafe int[][] DotWithTransposed(this int[][] a, float[,] b, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this int[,] a, float[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this int[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -37991,20 +38397,22 @@ public static unsafe int[][] DotWithTransposed(this int[,] a, float[][] b, int[]
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -38150,7 +38558,7 @@ public static int[][] DotWithTransposed(this int[][] a, float[] columnVector, in
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this int[,] a, float[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this int[,] a, float[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -38161,35 +38569,37 @@ public static int[][] DotWithTransposed(this int[][] a, float[] columnVector, in
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -38583,18 +38993,22 @@ public static int[][] DivideByDiagonal(this int[][] a, float[] diagonal, int[][]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this int[] a, float[] b, int[,] result)
+ public static int[,] Outer(this int[] a, float[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -38757,25 +39171,28 @@ public static int[][] Kronecker(this int[][] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this int[][] a, float[,] b, int[][] result)
+ public static int[][] Kronecker(this int[][] a, float[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -38829,18 +39246,22 @@ public static int[][] Kronecker(this int[,] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this int[] a, float[] b, int[] result)
+ public static int[] Kronecker(this int[] a, float[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -39034,7 +39455,7 @@ public static float[][] Dot(this int[][] a, float[,] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Dot(this int[,] a, float[][] b, float[][] result)
+ public static float[][] Dot(this int[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -39048,21 +39469,24 @@ public static unsafe float[][] Dot(this int[,] a, float[][] b, float[][] result)
var t = new float[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (float)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (float)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -39140,7 +39564,7 @@ public static float[] Dot(this int[][] matrix, float[] columnVector, float[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Dot(this int[,] matrix, float[] columnVector, float[] result)
+ public static float[] Dot(this int[,] matrix, float[] columnVector, float[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -39149,55 +39573,54 @@ public static unsafe float[] Dot(this int[,] matrix, float[] columnVector, float
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (float* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ float* pr = r;
- fixed (int* a = matrix)
- fixed (float* x = columnVector)
- fixed (float* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (float)sum1;
- *pr++ = (float)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (float)sum1;
+ *pr++ = (float)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (float)sum;
- }
- }
+ *pr = (float)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -39303,7 +39726,7 @@ public static float[] Dot(this int[] rowVector, float[][] matrix, float[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this int[][] a, float[,] b, float[][] result)
+ public static float[][] DotWithTransposed(this int[][] a, float[,] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -39313,19 +39736,22 @@ public static unsafe float[][] DotWithTransposed(this int[][] a, float[,] b, flo
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (float)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -39347,7 +39773,7 @@ public static unsafe float[][] DotWithTransposed(this int[][] a, float[,] b, flo
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this int[,] a, float[][] b, float[][] result)
+ public static float[][] DotWithTransposed(this int[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -39357,20 +39783,22 @@ public static unsafe float[][] DotWithTransposed(this int[,] a, float[][] b, flo
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (float)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -39516,7 +39944,7 @@ public static float[][] DotWithTransposed(this int[][] a, float[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] TransposeAndDot(this int[,] a, float[,] b, float[,] result)
+ public static float[,] TransposeAndDot(this int[,] a, float[,] b, float[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -39527,35 +39955,37 @@ public static float[][] DotWithTransposed(this int[][] a, float[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (float* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ float* pr = R;
- fixed (float* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- float* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (float)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (float)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -39949,18 +40379,22 @@ public static float[][] DivideByDiagonal(this int[][] a, float[] diagonal, float
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] Outer(this int[] a, float[] b, float[,] result)
+ public static float[,] Outer(this int[] a, float[] b, float[,] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -40123,25 +40557,28 @@ public static float[][] Kronecker(this int[][] a, float[][] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Kronecker(this int[][] a, float[,] b, float[][] result)
+ public static float[][] Kronecker(this int[][] a, float[,] b, float[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -40195,18 +40632,22 @@ public static float[][] Kronecker(this int[,] a, float[][] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Kronecker(this int[] a, float[] b, float[] result)
+ public static float[] Kronecker(this int[] a, float[] b, float[] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -40400,7 +40841,7 @@ public static double[][] Dot(this int[][] a, float[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this int[,] a, float[][] b, double[][] result)
+ public static double[][] Dot(this int[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -40414,21 +40855,24 @@ public static unsafe double[][] Dot(this int[,] a, float[][] b, double[][] resul
var t = new float[K];
- fixed (int* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- int* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ int* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -40506,7 +40950,7 @@ public static double[] Dot(this int[][] matrix, float[] columnVector, double[] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this int[,] matrix, float[] columnVector, double[] result)
+ public static double[] Dot(this int[,] matrix, float[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -40515,55 +40959,54 @@ public static unsafe double[] Dot(this int[,] matrix, float[] columnVector, doub
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (int* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (double* r = result)
+ {
+ int* pa1 = a;
+ int* pa2 = a + cols;
+ double* pr = r;
- fixed (int* a = matrix)
- fixed (float* x = columnVector)
- fixed (double* r = result)
- {
- int* pa1 = a;
- int* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -40669,7 +41112,7 @@ public static double[] Dot(this int[] rowVector, float[][] matrix, double[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this int[][] a, float[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this int[][] a, float[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -40679,19 +41122,22 @@ public static unsafe double[][] DotWithTransposed(this int[][] a, float[,] b, do
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- int[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ int[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -40713,7 +41159,7 @@ public static unsafe double[][] DotWithTransposed(this int[][] a, float[,] b, do
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this int[,] a, float[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this int[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -40723,20 +41169,22 @@ public static unsafe double[][] DotWithTransposed(this int[,] a, float[][] b, do
#endif
int n = a.Rows();
- fixed (int* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- int* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (int* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ int* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -40882,7 +41330,7 @@ public static double[][] DotWithTransposed(this int[][] a, float[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this int[,] a, float[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this int[,] a, float[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -40893,35 +41341,37 @@ public static double[][] DotWithTransposed(this int[][] a, float[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- int aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ int aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -41315,18 +41765,22 @@ public static double[][] DivideByDiagonal(this int[][] a, float[] diagonal, doub
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this int[] a, float[] b, double[,] result)
+ public static double[,] Outer(this int[] a, float[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -41489,25 +41943,28 @@ public static double[][] Kronecker(this int[][] a, float[][] b, double[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this int[][] a, float[,] b, double[][] result)
+ public static double[][] Kronecker(this int[][] a, float[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -41561,18 +42018,22 @@ public static double[][] Kronecker(this int[,] a, float[][] b, double[][] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this int[] a, float[] b, double[] result)
+ public static double[] Kronecker(this int[] a, float[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -41766,7 +42227,7 @@ public static double[][] Dot(this double[][] a, double[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this double[,] a, double[][] b, double[][] result)
+ public static double[][] Dot(this double[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -41780,21 +42241,24 @@ public static unsafe double[][] Dot(this double[,] a, double[][] b, double[][] r
var t = new double[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -41872,7 +42336,7 @@ public static double[] Dot(this double[][] matrix, double[] columnVector, double
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this double[,] matrix, double[] columnVector, double[] result)
+ public static double[] Dot(this double[,] matrix, double[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -41881,55 +42345,54 @@ public static unsafe double[] Dot(this double[,] matrix, double[] columnVector,
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (double* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ double* pr = r;
- fixed (double* a = matrix)
- fixed (double* x = columnVector)
- fixed (double* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -42035,7 +42498,7 @@ public static double[] Dot(this double[] rowVector, double[][] matrix, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this double[][] a, double[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this double[][] a, double[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -42045,19 +42508,22 @@ public static unsafe double[][] DotWithTransposed(this double[][] a, double[,] b
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -42079,7 +42545,7 @@ public static unsafe double[][] DotWithTransposed(this double[][] a, double[,] b
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this double[,] a, double[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this double[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -42089,20 +42555,22 @@ public static unsafe double[][] DotWithTransposed(this double[,] a, double[][] b
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -42248,7 +42716,7 @@ public static double[][] DotWithTransposed(this double[][] a, double[] columnVec
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this double[,] a, double[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this double[,] a, double[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -42259,35 +42727,37 @@ public static double[][] DotWithTransposed(this double[][] a, double[] columnVec
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (double* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (double* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -42681,18 +43151,22 @@ public static double[][] DivideByDiagonal(this double[][] a, double[] diagonal,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this double[] a, double[] b, double[,] result)
+ public static double[,] Outer(this double[] a, double[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -42855,25 +43329,28 @@ public static double[][] Kronecker(this double[][] a, double[][] b, double[][] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this double[][] a, double[,] b, double[][] result)
+ public static double[][] Kronecker(this double[][] a, double[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -42927,18 +43404,22 @@ public static double[][] Kronecker(this double[,] a, double[][] b, double[][] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this double[] a, double[] b, double[] result)
+ public static double[] Kronecker(this double[] a, double[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -43132,7 +43613,7 @@ public static int[][] Dot(this double[][] a, double[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this double[,] a, double[][] b, int[][] result)
+ public static int[][] Dot(this double[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -43146,21 +43627,24 @@ public static unsafe int[][] Dot(this double[,] a, double[][] b, int[][] result)
var t = new double[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -43238,7 +43722,7 @@ public static int[] Dot(this double[][] matrix, double[] columnVector, int[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this double[,] matrix, double[] columnVector, int[] result)
+ public static int[] Dot(this double[,] matrix, double[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -43247,55 +43731,54 @@ public static unsafe int[] Dot(this double[,] matrix, double[] columnVector, int
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (int* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ int* pr = r;
- fixed (double* a = matrix)
- fixed (double* x = columnVector)
- fixed (int* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -43401,7 +43884,7 @@ public static int[] Dot(this double[] rowVector, double[][] matrix, int[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this double[][] a, double[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this double[][] a, double[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -43411,19 +43894,22 @@ public static unsafe int[][] DotWithTransposed(this double[][] a, double[,] b, i
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -43445,7 +43931,7 @@ public static unsafe int[][] DotWithTransposed(this double[][] a, double[,] b, i
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this double[,] a, double[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this double[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -43455,20 +43941,22 @@ public static unsafe int[][] DotWithTransposed(this double[,] a, double[][] b, i
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -43614,7 +44102,7 @@ public static int[][] DotWithTransposed(this double[][] a, double[] columnVector
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this double[,] a, double[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this double[,] a, double[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -43625,35 +44113,37 @@ public static int[][] DotWithTransposed(this double[][] a, double[] columnVector
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (double* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (double* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -44047,18 +44537,22 @@ public static int[][] DivideByDiagonal(this double[][] a, double[] diagonal, int
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this double[] a, double[] b, int[,] result)
+ public static int[,] Outer(this double[] a, double[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -44221,25 +44715,28 @@ public static int[][] Kronecker(this double[][] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this double[][] a, double[,] b, int[][] result)
+ public static int[][] Kronecker(this double[][] a, double[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -44293,18 +44790,22 @@ public static int[][] Kronecker(this double[,] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this double[] a, double[] b, int[] result)
+ public static int[] Kronecker(this double[] a, double[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -44498,7 +44999,7 @@ public static double[][] Dot(this double[][] a, int[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this double[,] a, int[][] b, double[][] result)
+ public static double[][] Dot(this double[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -44512,21 +45013,24 @@ public static unsafe double[][] Dot(this double[,] a, int[][] b, double[][] resu
var t = new int[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -44604,7 +45108,7 @@ public static double[] Dot(this double[][] matrix, int[] columnVector, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this double[,] matrix, int[] columnVector, double[] result)
+ public static double[] Dot(this double[,] matrix, int[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -44613,55 +45117,54 @@ public static unsafe double[] Dot(this double[,] matrix, int[] columnVector, dou
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (double* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ double* pr = r;
- fixed (double* a = matrix)
- fixed (int* x = columnVector)
- fixed (double* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -44767,7 +45270,7 @@ public static double[] Dot(this double[] rowVector, int[][] matrix, double[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this double[][] a, int[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this double[][] a, int[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -44777,19 +45280,22 @@ public static unsafe double[][] DotWithTransposed(this double[][] a, int[,] b, d
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -44811,7 +45317,7 @@ public static unsafe double[][] DotWithTransposed(this double[][] a, int[,] b, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this double[,] a, int[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this double[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -44821,20 +45327,22 @@ public static unsafe double[][] DotWithTransposed(this double[,] a, int[][] b, d
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -44980,7 +45488,7 @@ public static double[][] DotWithTransposed(this double[][] a, int[] columnVector
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this double[,] a, int[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this double[,] a, int[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -44991,35 +45499,37 @@ public static double[][] DotWithTransposed(this double[][] a, int[] columnVector
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (int* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (int* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -45413,18 +45923,22 @@ public static double[][] DivideByDiagonal(this double[][] a, int[] diagonal, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this double[] a, int[] b, double[,] result)
+ public static double[,] Outer(this double[] a, int[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -45587,25 +46101,28 @@ public static double[][] Kronecker(this double[][] a, int[][] b, double[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this double[][] a, int[,] b, double[][] result)
+ public static double[][] Kronecker(this double[][] a, int[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -45659,18 +46176,22 @@ public static double[][] Kronecker(this double[,] a, int[][] b, double[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this double[] a, int[] b, double[] result)
+ public static double[] Kronecker(this double[] a, int[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -45864,7 +46385,7 @@ public static int[][] Dot(this double[][] a, int[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this double[,] a, int[][] b, int[][] result)
+ public static int[][] Dot(this double[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -45878,21 +46399,24 @@ public static unsafe int[][] Dot(this double[,] a, int[][] b, int[][] result)
var t = new int[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -45970,7 +46494,7 @@ public static int[] Dot(this double[][] matrix, int[] columnVector, int[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this double[,] matrix, int[] columnVector, int[] result)
+ public static int[] Dot(this double[,] matrix, int[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -45979,55 +46503,54 @@ public static unsafe int[] Dot(this double[,] matrix, int[] columnVector, int[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (int* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ int* pr = r;
- fixed (double* a = matrix)
- fixed (int* x = columnVector)
- fixed (int* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -46133,7 +46656,7 @@ public static int[] Dot(this double[] rowVector, int[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this double[][] a, int[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this double[][] a, int[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -46143,19 +46666,22 @@ public static unsafe int[][] DotWithTransposed(this double[][] a, int[,] b, int[
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -46177,7 +46703,7 @@ public static unsafe int[][] DotWithTransposed(this double[][] a, int[,] b, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this double[,] a, int[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this double[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -46187,20 +46713,22 @@ public static unsafe int[][] DotWithTransposed(this double[,] a, int[][] b, int[
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -46346,7 +46874,7 @@ public static int[][] DotWithTransposed(this double[][] a, int[] columnVector, i
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this double[,] a, int[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this double[,] a, int[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -46357,35 +46885,37 @@ public static int[][] DotWithTransposed(this double[][] a, int[] columnVector, i
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (int* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (int* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -46779,18 +47309,22 @@ public static int[][] DivideByDiagonal(this double[][] a, int[] diagonal, int[][
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this double[] a, int[] b, int[,] result)
+ public static int[,] Outer(this double[] a, int[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -46953,25 +47487,28 @@ public static int[][] Kronecker(this double[][] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this double[][] a, int[,] b, int[][] result)
+ public static int[][] Kronecker(this double[][] a, int[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -47025,18 +47562,22 @@ public static int[][] Kronecker(this double[,] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this double[] a, int[] b, int[] result)
+ public static int[] Kronecker(this double[] a, int[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -47230,7 +47771,7 @@ public static double[][] Dot(this double[][] a, float[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this double[,] a, float[][] b, double[][] result)
+ public static double[][] Dot(this double[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -47244,21 +47785,24 @@ public static unsafe double[][] Dot(this double[,] a, float[][] b, double[][] re
var t = new float[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -47336,7 +47880,7 @@ public static double[] Dot(this double[][] matrix, float[] columnVector, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this double[,] matrix, float[] columnVector, double[] result)
+ public static double[] Dot(this double[,] matrix, float[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -47345,55 +47889,54 @@ public static unsafe double[] Dot(this double[,] matrix, float[] columnVector, d
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (double* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ double* pr = r;
- fixed (double* a = matrix)
- fixed (float* x = columnVector)
- fixed (double* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -47499,7 +48042,7 @@ public static double[] Dot(this double[] rowVector, float[][] matrix, double[] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this double[][] a, float[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this double[][] a, float[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -47509,19 +48052,22 @@ public static unsafe double[][] DotWithTransposed(this double[][] a, float[,] b,
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -47543,7 +48089,7 @@ public static unsafe double[][] DotWithTransposed(this double[][] a, float[,] b,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this double[,] a, float[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this double[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -47553,20 +48099,22 @@ public static unsafe double[][] DotWithTransposed(this double[,] a, float[][] b,
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -47712,7 +48260,7 @@ public static double[][] DotWithTransposed(this double[][] a, float[] columnVect
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this double[,] a, float[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this double[,] a, float[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -47723,35 +48271,37 @@ public static double[][] DotWithTransposed(this double[][] a, float[] columnVect
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -48145,18 +48695,22 @@ public static double[][] DivideByDiagonal(this double[][] a, float[] diagonal, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this double[] a, float[] b, double[,] result)
+ public static double[,] Outer(this double[] a, float[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -48319,25 +48873,28 @@ public static double[][] Kronecker(this double[][] a, float[][] b, double[][] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this double[][] a, float[,] b, double[][] result)
+ public static double[][] Kronecker(this double[][] a, float[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -48391,18 +48948,22 @@ public static double[][] Kronecker(this double[,] a, float[][] b, double[][] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this double[] a, float[] b, double[] result)
+ public static double[] Kronecker(this double[] a, float[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -48596,7 +49157,7 @@ public static float[][] Dot(this double[][] a, float[,] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Dot(this double[,] a, float[][] b, float[][] result)
+ public static float[][] Dot(this double[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -48610,21 +49171,24 @@ public static unsafe float[][] Dot(this double[,] a, float[][] b, float[][] resu
var t = new float[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (float)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (float)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -48702,7 +49266,7 @@ public static float[] Dot(this double[][] matrix, float[] columnVector, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Dot(this double[,] matrix, float[] columnVector, float[] result)
+ public static float[] Dot(this double[,] matrix, float[] columnVector, float[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -48711,55 +49275,54 @@ public static unsafe float[] Dot(this double[,] matrix, float[] columnVector, fl
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (float* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ float* pr = r;
- fixed (double* a = matrix)
- fixed (float* x = columnVector)
- fixed (float* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (float)sum1;
- *pr++ = (float)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (float)sum1;
+ *pr++ = (float)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (float)sum;
- }
- }
+ *pr = (float)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -48865,7 +49428,7 @@ public static float[] Dot(this double[] rowVector, float[][] matrix, float[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this double[][] a, float[,] b, float[][] result)
+ public static float[][] DotWithTransposed(this double[][] a, float[,] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -48875,19 +49438,22 @@ public static unsafe float[][] DotWithTransposed(this double[][] a, float[,] b,
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (float)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -48909,7 +49475,7 @@ public static unsafe float[][] DotWithTransposed(this double[][] a, float[,] b,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this double[,] a, float[][] b, float[][] result)
+ public static float[][] DotWithTransposed(this double[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -48919,20 +49485,22 @@ public static unsafe float[][] DotWithTransposed(this double[,] a, float[][] b,
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (float)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -49078,7 +49646,7 @@ public static float[][] DotWithTransposed(this double[][] a, float[] columnVecto
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] TransposeAndDot(this double[,] a, float[,] b, float[,] result)
+ public static float[,] TransposeAndDot(this double[,] a, float[,] b, float[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -49089,35 +49657,37 @@ public static float[][] DotWithTransposed(this double[][] a, float[] columnVecto
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (float* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ float* pr = R;
- fixed (float* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- float* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (float)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (float)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -49511,18 +50081,22 @@ public static float[][] DivideByDiagonal(this double[][] a, float[] diagonal, fl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] Outer(this double[] a, float[] b, float[,] result)
+ public static float[,] Outer(this double[] a, float[] b, float[,] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -49685,25 +50259,28 @@ public static float[][] Kronecker(this double[][] a, float[][] b, float[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Kronecker(this double[][] a, float[,] b, float[][] result)
+ public static float[][] Kronecker(this double[][] a, float[,] b, float[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -49757,18 +50334,22 @@ public static float[][] Kronecker(this double[,] a, float[][] b, float[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Kronecker(this double[] a, float[] b, float[] result)
+ public static float[] Kronecker(this double[] a, float[] b, float[] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -49962,7 +50543,7 @@ public static int[][] Dot(this double[][] a, float[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this double[,] a, float[][] b, int[][] result)
+ public static int[][] Dot(this double[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -49976,21 +50557,24 @@ public static unsafe int[][] Dot(this double[,] a, float[][] b, int[][] result)
var t = new float[K];
- fixed (double* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- double* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (int)s;
- }
- }
+ double* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -50068,7 +50652,7 @@ public static int[] Dot(this double[][] matrix, float[] columnVector, int[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this double[,] matrix, float[] columnVector, int[] result)
+ public static int[] Dot(this double[,] matrix, float[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -50077,55 +50661,54 @@ public static unsafe int[] Dot(this double[,] matrix, float[] columnVector, int[
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (double* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (int* r = result)
+ {
+ double* pa1 = a;
+ double* pa2 = a + cols;
+ int* pr = r;
- fixed (double* a = matrix)
- fixed (float* x = columnVector)
- fixed (int* r = result)
- {
- double* pa1 = a;
- double* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -50231,7 +50814,7 @@ public static int[] Dot(this double[] rowVector, float[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this double[][] a, float[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this double[][] a, float[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -50241,19 +50824,22 @@ public static unsafe int[][] DotWithTransposed(this double[][] a, float[,] b, in
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- double[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ double[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -50275,7 +50861,7 @@ public static unsafe int[][] DotWithTransposed(this double[][] a, float[,] b, in
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this double[,] a, float[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this double[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -50285,20 +50871,22 @@ public static unsafe int[][] DotWithTransposed(this double[,] a, float[][] b, in
#endif
int n = a.Rows();
- fixed (double* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- double* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (double* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ double* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -50444,7 +51032,7 @@ public static int[][] DotWithTransposed(this double[][] a, float[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this double[,] a, float[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this double[,] a, float[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -50455,35 +51043,37 @@ public static int[][] DotWithTransposed(this double[][] a, float[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- double aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ double aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -50877,18 +51467,22 @@ public static int[][] DivideByDiagonal(this double[][] a, float[] diagonal, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this double[] a, float[] b, int[,] result)
+ public static int[,] Outer(this double[] a, float[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -51051,25 +51645,28 @@ public static int[][] Kronecker(this double[][] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this double[][] a, float[,] b, int[][] result)
+ public static int[][] Kronecker(this double[][] a, float[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -51123,18 +51720,22 @@ public static int[][] Kronecker(this double[,] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this double[] a, float[] b, int[] result)
+ public static int[] Kronecker(this double[] a, float[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -51328,7 +51929,7 @@ public static float[][] Dot(this float[][] a, float[,] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Dot(this float[,] a, float[][] b, float[][] result)
+ public static float[][] Dot(this float[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -51342,21 +51943,24 @@ public static unsafe float[][] Dot(this float[,] a, float[][] b, float[][] resul
var t = new float[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (float)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (float)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -51434,7 +52038,7 @@ public static float[] Dot(this float[][] matrix, float[] columnVector, float[] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Dot(this float[,] matrix, float[] columnVector, float[] result)
+ public static float[] Dot(this float[,] matrix, float[] columnVector, float[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -51443,55 +52047,54 @@ public static unsafe float[] Dot(this float[,] matrix, float[] columnVector, flo
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (float* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ float* pr = r;
- fixed (float* a = matrix)
- fixed (float* x = columnVector)
- fixed (float* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (float)sum1;
- *pr++ = (float)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (float)sum1;
+ *pr++ = (float)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (float)sum;
- }
- }
+ *pr = (float)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -51597,7 +52200,7 @@ public static float[] Dot(this float[] rowVector, float[][] matrix, float[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this float[][] a, float[,] b, float[][] result)
+ public static float[][] DotWithTransposed(this float[][] a, float[,] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -51607,19 +52210,22 @@ public static unsafe float[][] DotWithTransposed(this float[][] a, float[,] b, f
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (float)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -51641,7 +52247,7 @@ public static unsafe float[][] DotWithTransposed(this float[][] a, float[,] b, f
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this float[,] a, float[][] b, float[][] result)
+ public static float[][] DotWithTransposed(this float[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -51651,20 +52257,22 @@ public static unsafe float[][] DotWithTransposed(this float[,] a, float[][] b, f
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (float)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -51810,7 +52418,7 @@ public static float[][] DotWithTransposed(this float[][] a, float[] columnVector
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] TransposeAndDot(this float[,] a, float[,] b, float[,] result)
+ public static float[,] TransposeAndDot(this float[,] a, float[,] b, float[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -51821,35 +52429,37 @@ public static float[][] DotWithTransposed(this float[][] a, float[] columnVector
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (float* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ float* pr = R;
- fixed (float* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- float* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (float)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (float)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -52243,18 +52853,22 @@ public static float[][] DivideByDiagonal(this float[][] a, float[] diagonal, flo
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] Outer(this float[] a, float[] b, float[,] result)
+ public static float[,] Outer(this float[] a, float[] b, float[,] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -52417,25 +53031,28 @@ public static float[][] Kronecker(this float[][] a, float[][] b, float[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Kronecker(this float[][] a, float[,] b, float[][] result)
+ public static float[][] Kronecker(this float[][] a, float[,] b, float[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -52489,18 +53106,22 @@ public static float[][] Kronecker(this float[,] a, float[][] b, float[][] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Kronecker(this float[] a, float[] b, float[] result)
+ public static float[] Kronecker(this float[] a, float[] b, float[] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -52694,7 +53315,7 @@ public static double[][] Dot(this float[][] a, float[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this float[,] a, float[][] b, double[][] result)
+ public static double[][] Dot(this float[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -52708,21 +53329,24 @@ public static unsafe double[][] Dot(this float[,] a, float[][] b, double[][] res
var t = new float[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -52800,7 +53424,7 @@ public static double[] Dot(this float[][] matrix, float[] columnVector, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this float[,] matrix, float[] columnVector, double[] result)
+ public static double[] Dot(this float[,] matrix, float[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -52809,55 +53433,54 @@ public static unsafe double[] Dot(this float[,] matrix, float[] columnVector, do
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (double* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ double* pr = r;
- fixed (float* a = matrix)
- fixed (float* x = columnVector)
- fixed (double* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -52963,7 +53586,7 @@ public static double[] Dot(this float[] rowVector, float[][] matrix, double[] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this float[][] a, float[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this float[][] a, float[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -52973,19 +53596,22 @@ public static unsafe double[][] DotWithTransposed(this float[][] a, float[,] b,
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -53007,7 +53633,7 @@ public static unsafe double[][] DotWithTransposed(this float[][] a, float[,] b,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this float[,] a, float[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this float[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -53017,20 +53643,22 @@ public static unsafe double[][] DotWithTransposed(this float[,] a, float[][] b,
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -53176,7 +53804,7 @@ public static double[][] DotWithTransposed(this float[][] a, float[] columnVecto
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this float[,] a, float[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this float[,] a, float[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -53187,35 +53815,37 @@ public static double[][] DotWithTransposed(this float[][] a, float[] columnVecto
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -53609,18 +54239,22 @@ public static double[][] DivideByDiagonal(this float[][] a, float[] diagonal, do
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this float[] a, float[] b, double[,] result)
+ public static double[,] Outer(this float[] a, float[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -53783,25 +54417,28 @@ public static double[][] Kronecker(this float[][] a, float[][] b, double[][] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this float[][] a, float[,] b, double[][] result)
+ public static double[][] Kronecker(this float[][] a, float[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -53855,18 +54492,22 @@ public static double[][] Kronecker(this float[,] a, float[][] b, double[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this float[] a, float[] b, double[] result)
+ public static double[] Kronecker(this float[] a, float[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -54060,7 +54701,7 @@ public static int[][] Dot(this float[][] a, float[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this float[,] a, float[][] b, int[][] result)
+ public static int[][] Dot(this float[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -54074,21 +54715,24 @@ public static unsafe int[][] Dot(this float[,] a, float[][] b, int[][] result)
var t = new float[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (int)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -54166,7 +54810,7 @@ public static int[] Dot(this float[][] matrix, float[] columnVector, int[] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this float[,] matrix, float[] columnVector, int[] result)
+ public static int[] Dot(this float[,] matrix, float[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -54175,55 +54819,54 @@ public static unsafe int[] Dot(this float[,] matrix, float[] columnVector, int[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (int* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ int* pr = r;
- fixed (float* a = matrix)
- fixed (float* x = columnVector)
- fixed (int* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -54329,7 +54972,7 @@ public static int[] Dot(this float[] rowVector, float[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this float[][] a, float[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this float[][] a, float[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -54339,19 +54982,22 @@ public static unsafe int[][] DotWithTransposed(this float[][] a, float[,] b, int
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -54373,7 +55019,7 @@ public static unsafe int[][] DotWithTransposed(this float[][] a, float[,] b, int
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this float[,] a, float[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this float[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -54383,20 +55029,22 @@ public static unsafe int[][] DotWithTransposed(this float[,] a, float[][] b, int
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -54542,7 +55190,7 @@ public static int[][] DotWithTransposed(this float[][] a, float[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this float[,] a, float[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this float[,] a, float[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -54553,35 +55201,37 @@ public static int[][] DotWithTransposed(this float[][] a, float[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -54975,18 +55625,22 @@ public static int[][] DivideByDiagonal(this float[][] a, float[] diagonal, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this float[] a, float[] b, int[,] result)
+ public static int[,] Outer(this float[] a, float[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -55149,25 +55803,28 @@ public static int[][] Kronecker(this float[][] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this float[][] a, float[,] b, int[][] result)
+ public static int[][] Kronecker(this float[][] a, float[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -55221,18 +55878,22 @@ public static int[][] Kronecker(this float[,] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this float[] a, float[] b, int[] result)
+ public static int[] Kronecker(this float[] a, float[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -55426,7 +56087,7 @@ public static float[][] Dot(this float[][] a, double[,] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Dot(this float[,] a, double[][] b, float[][] result)
+ public static float[][] Dot(this float[,] a, double[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -55440,21 +56101,24 @@ public static unsafe float[][] Dot(this float[,] a, double[][] b, float[][] resu
var t = new double[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (float)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (float)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -55532,7 +56196,7 @@ public static float[] Dot(this float[][] matrix, double[] columnVector, float[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Dot(this float[,] matrix, double[] columnVector, float[] result)
+ public static float[] Dot(this float[,] matrix, double[] columnVector, float[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -55541,55 +56205,54 @@ public static unsafe float[] Dot(this float[,] matrix, double[] columnVector, fl
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (float* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ float* pr = r;
- fixed (float* a = matrix)
- fixed (double* x = columnVector)
- fixed (float* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (float)sum1;
- *pr++ = (float)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (float)sum1;
+ *pr++ = (float)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (float)sum;
- }
- }
+ *pr = (float)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -55695,7 +56358,7 @@ public static float[] Dot(this float[] rowVector, double[][] matrix, float[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this float[][] a, double[,] b, float[][] result)
+ public static float[][] DotWithTransposed(this float[][] a, double[,] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -55705,19 +56368,22 @@ public static unsafe float[][] DotWithTransposed(this float[][] a, double[,] b,
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (float)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -55739,7 +56405,7 @@ public static unsafe float[][] DotWithTransposed(this float[][] a, double[,] b,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this float[,] a, double[][] b, float[][] result)
+ public static float[][] DotWithTransposed(this float[,] a, double[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -55749,20 +56415,22 @@ public static unsafe float[][] DotWithTransposed(this float[,] a, double[][] b,
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (float)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -55908,7 +56576,7 @@ public static float[][] DotWithTransposed(this float[][] a, double[] columnVecto
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] TransposeAndDot(this float[,] a, double[,] b, float[,] result)
+ public static float[,] TransposeAndDot(this float[,] a, double[,] b, float[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -55919,35 +56587,37 @@ public static float[][] DotWithTransposed(this float[][] a, double[] columnVecto
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (float* R = result)
+ fixed (double* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ float* pr = R;
- fixed (float* R = result)
- fixed (double* B = b)
- fixed (double* ptemp = new double[p])
- {
- float* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (float)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (float)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -56341,18 +57011,22 @@ public static float[][] DivideByDiagonal(this float[][] a, double[] diagonal, fl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] Outer(this float[] a, double[] b, float[,] result)
+ public static float[,] Outer(this float[] a, double[] b, float[,] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -56515,25 +57189,28 @@ public static float[][] Kronecker(this float[][] a, double[][] b, float[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Kronecker(this float[][] a, double[,] b, float[][] result)
+ public static float[][] Kronecker(this float[][] a, double[,] b, float[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -56587,18 +57264,22 @@ public static float[][] Kronecker(this float[,] a, double[][] b, float[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Kronecker(this float[] a, double[] b, float[] result)
+ public static float[] Kronecker(this float[] a, double[] b, float[] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -56792,7 +57473,7 @@ public static double[][] Dot(this float[][] a, double[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this float[,] a, double[][] b, double[][] result)
+ public static double[][] Dot(this float[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -56806,21 +57487,24 @@ public static unsafe double[][] Dot(this float[,] a, double[][] b, double[][] re
var t = new double[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -56898,7 +57582,7 @@ public static double[] Dot(this float[][] matrix, double[] columnVector, double[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this float[,] matrix, double[] columnVector, double[] result)
+ public static double[] Dot(this float[,] matrix, double[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -56907,55 +57591,54 @@ public static unsafe double[] Dot(this float[,] matrix, double[] columnVector, d
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (double* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ double* pr = r;
- fixed (float* a = matrix)
- fixed (double* x = columnVector)
- fixed (double* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -57061,7 +57744,7 @@ public static double[] Dot(this float[] rowVector, double[][] matrix, double[] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this float[][] a, double[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this float[][] a, double[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -57071,19 +57754,22 @@ public static unsafe double[][] DotWithTransposed(this float[][] a, double[,] b,
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -57105,7 +57791,7 @@ public static unsafe double[][] DotWithTransposed(this float[][] a, double[,] b,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this float[,] a, double[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this float[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -57115,20 +57801,22 @@ public static unsafe double[][] DotWithTransposed(this float[,] a, double[][] b,
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -57274,7 +57962,7 @@ public static double[][] DotWithTransposed(this float[][] a, double[] columnVect
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this float[,] a, double[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this float[,] a, double[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -57285,35 +57973,37 @@ public static double[][] DotWithTransposed(this float[][] a, double[] columnVect
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (double* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (double* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -57707,18 +58397,22 @@ public static double[][] DivideByDiagonal(this float[][] a, double[] diagonal, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this float[] a, double[] b, double[,] result)
+ public static double[,] Outer(this float[] a, double[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -57881,25 +58575,28 @@ public static double[][] Kronecker(this float[][] a, double[][] b, double[][] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this float[][] a, double[,] b, double[][] result)
+ public static double[][] Kronecker(this float[][] a, double[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -57953,18 +58650,22 @@ public static double[][] Kronecker(this float[,] a, double[][] b, double[][] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this float[] a, double[] b, double[] result)
+ public static double[] Kronecker(this float[] a, double[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -58158,7 +58859,7 @@ public static int[][] Dot(this float[][] a, double[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this float[,] a, double[][] b, int[][] result)
+ public static int[][] Dot(this float[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -58172,21 +58873,24 @@ public static unsafe int[][] Dot(this float[,] a, double[][] b, int[][] result)
var t = new double[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (int)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -58264,7 +58968,7 @@ public static int[] Dot(this float[][] matrix, double[] columnVector, int[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this float[,] matrix, double[] columnVector, int[] result)
+ public static int[] Dot(this float[,] matrix, double[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -58273,55 +58977,54 @@ public static unsafe int[] Dot(this float[,] matrix, double[] columnVector, int[
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (int* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ int* pr = r;
- fixed (float* a = matrix)
- fixed (double* x = columnVector)
- fixed (int* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -58427,7 +59130,7 @@ public static int[] Dot(this float[] rowVector, double[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this float[][] a, double[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this float[][] a, double[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -58437,19 +59140,22 @@ public static unsafe int[][] DotWithTransposed(this float[][] a, double[,] b, in
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -58471,7 +59177,7 @@ public static unsafe int[][] DotWithTransposed(this float[][] a, double[,] b, in
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this float[,] a, double[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this float[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -58481,20 +59187,22 @@ public static unsafe int[][] DotWithTransposed(this float[,] a, double[][] b, in
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -58640,7 +59348,7 @@ public static int[][] DotWithTransposed(this float[][] a, double[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this float[,] a, double[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this float[,] a, double[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -58651,35 +59359,37 @@ public static int[][] DotWithTransposed(this float[][] a, double[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (double* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (double* B = b)
- fixed (double* ptemp = new double[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -59073,18 +59783,22 @@ public static int[][] DivideByDiagonal(this float[][] a, double[] diagonal, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this float[] a, double[] b, int[,] result)
+ public static int[,] Outer(this float[] a, double[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -59247,25 +59961,28 @@ public static int[][] Kronecker(this float[][] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this float[][] a, double[,] b, int[][] result)
+ public static int[][] Kronecker(this float[][] a, double[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -59319,18 +60036,22 @@ public static int[][] Kronecker(this float[,] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this float[] a, double[] b, int[] result)
+ public static int[] Kronecker(this float[] a, double[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -59524,7 +60245,7 @@ public static float[][] Dot(this float[][] a, int[,] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Dot(this float[,] a, int[][] b, float[][] result)
+ public static float[][] Dot(this float[,] a, int[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -59538,21 +60259,24 @@ public static unsafe float[][] Dot(this float[,] a, int[][] b, float[][] result)
var t = new int[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (float)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (float)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -59630,7 +60354,7 @@ public static float[] Dot(this float[][] matrix, int[] columnVector, float[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Dot(this float[,] matrix, int[] columnVector, float[] result)
+ public static float[] Dot(this float[,] matrix, int[] columnVector, float[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -59639,55 +60363,54 @@ public static unsafe float[] Dot(this float[,] matrix, int[] columnVector, float
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (float* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ float* pr = r;
- fixed (float* a = matrix)
- fixed (int* x = columnVector)
- fixed (float* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (float)sum1;
- *pr++ = (float)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (float)sum1;
+ *pr++ = (float)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (float)sum;
- }
- }
+ *pr = (float)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -59793,7 +60516,7 @@ public static float[] Dot(this float[] rowVector, int[][] matrix, float[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this float[][] a, int[,] b, float[][] result)
+ public static float[][] DotWithTransposed(this float[][] a, int[,] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -59803,19 +60526,22 @@ public static unsafe float[][] DotWithTransposed(this float[][] a, int[,] b, flo
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (float)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -59837,7 +60563,7 @@ public static unsafe float[][] DotWithTransposed(this float[][] a, int[,] b, flo
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this float[,] a, int[][] b, float[][] result)
+ public static float[][] DotWithTransposed(this float[,] a, int[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -59847,20 +60573,22 @@ public static unsafe float[][] DotWithTransposed(this float[,] a, int[][] b, flo
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (float)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -60006,7 +60734,7 @@ public static float[][] DotWithTransposed(this float[][] a, int[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] TransposeAndDot(this float[,] a, int[,] b, float[,] result)
+ public static float[,] TransposeAndDot(this float[,] a, int[,] b, float[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -60017,35 +60745,37 @@ public static float[][] DotWithTransposed(this float[][] a, int[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (float* R = result)
+ fixed (int* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ float* pr = R;
- fixed (float* R = result)
- fixed (int* B = b)
- fixed (double* ptemp = new double[p])
- {
- float* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (float)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (float)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -60439,18 +61169,22 @@ public static float[][] DivideByDiagonal(this float[][] a, int[] diagonal, float
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] Outer(this float[] a, int[] b, float[,] result)
+ public static float[,] Outer(this float[] a, int[] b, float[,] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -60613,25 +61347,28 @@ public static float[][] Kronecker(this float[][] a, int[][] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Kronecker(this float[][] a, int[,] b, float[][] result)
+ public static float[][] Kronecker(this float[][] a, int[,] b, float[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -60685,18 +61422,22 @@ public static float[][] Kronecker(this float[,] a, int[][] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Kronecker(this float[] a, int[] b, float[] result)
+ public static float[] Kronecker(this float[] a, int[] b, float[] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -60890,7 +61631,7 @@ public static int[][] Dot(this float[][] a, int[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this float[,] a, int[][] b, int[][] result)
+ public static int[][] Dot(this float[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -60904,21 +61645,24 @@ public static unsafe int[][] Dot(this float[,] a, int[][] b, int[][] result)
var t = new int[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (int)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -60996,7 +61740,7 @@ public static int[] Dot(this float[][] matrix, int[] columnVector, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this float[,] matrix, int[] columnVector, int[] result)
+ public static int[] Dot(this float[,] matrix, int[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -61005,55 +61749,54 @@ public static unsafe int[] Dot(this float[,] matrix, int[] columnVector, int[] r
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (int* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ int* pr = r;
- fixed (float* a = matrix)
- fixed (int* x = columnVector)
- fixed (int* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -61159,7 +61902,7 @@ public static int[] Dot(this float[] rowVector, int[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this float[][] a, int[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this float[][] a, int[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -61169,19 +61912,22 @@ public static unsafe int[][] DotWithTransposed(this float[][] a, int[,] b, int[]
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -61203,7 +61949,7 @@ public static unsafe int[][] DotWithTransposed(this float[][] a, int[,] b, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this float[,] a, int[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this float[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -61213,20 +61959,22 @@ public static unsafe int[][] DotWithTransposed(this float[,] a, int[][] b, int[]
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -61372,7 +62120,7 @@ public static int[][] DotWithTransposed(this float[][] a, int[] columnVector, in
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this float[,] a, int[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this float[,] a, int[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -61383,35 +62131,37 @@ public static int[][] DotWithTransposed(this float[][] a, int[] columnVector, in
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (int* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (int* B = b)
- fixed (double* ptemp = new double[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -61805,18 +62555,22 @@ public static int[][] DivideByDiagonal(this float[][] a, int[] diagonal, int[][]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this float[] a, int[] b, int[,] result)
+ public static int[,] Outer(this float[] a, int[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -61979,25 +62733,28 @@ public static int[][] Kronecker(this float[][] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this float[][] a, int[,] b, int[][] result)
+ public static int[][] Kronecker(this float[][] a, int[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -62051,18 +62808,22 @@ public static int[][] Kronecker(this float[,] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this float[] a, int[] b, int[] result)
+ public static int[] Kronecker(this float[] a, int[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -62256,7 +63017,7 @@ public static double[][] Dot(this float[][] a, int[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this float[,] a, int[][] b, double[][] result)
+ public static double[][] Dot(this float[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -62270,21 +63031,24 @@ public static unsafe double[][] Dot(this float[,] a, int[][] b, double[][] resul
var t = new int[K];
- fixed (float* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- float* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ float* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -62362,7 +63126,7 @@ public static double[] Dot(this float[][] matrix, int[] columnVector, double[] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this float[,] matrix, int[] columnVector, double[] result)
+ public static double[] Dot(this float[,] matrix, int[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -62371,55 +63135,54 @@ public static unsafe double[] Dot(this float[,] matrix, int[] columnVector, doub
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (float* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (double* r = result)
+ {
+ float* pa1 = a;
+ float* pa2 = a + cols;
+ double* pr = r;
- fixed (float* a = matrix)
- fixed (int* x = columnVector)
- fixed (double* r = result)
- {
- float* pa1 = a;
- float* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -62525,7 +63288,7 @@ public static double[] Dot(this float[] rowVector, int[][] matrix, double[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this float[][] a, int[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this float[][] a, int[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -62535,19 +63298,22 @@ public static unsafe double[][] DotWithTransposed(this float[][] a, int[,] b, do
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- float[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ float[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -62569,7 +63335,7 @@ public static unsafe double[][] DotWithTransposed(this float[][] a, int[,] b, do
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this float[,] a, int[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this float[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -62579,20 +63345,22 @@ public static unsafe double[][] DotWithTransposed(this float[,] a, int[][] b, do
#endif
int n = a.Rows();
- fixed (float* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- float* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (float* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ float* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -62738,7 +63506,7 @@ public static double[][] DotWithTransposed(this float[][] a, int[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this float[,] a, int[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this float[,] a, int[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -62749,35 +63517,37 @@ public static double[][] DotWithTransposed(this float[][] a, int[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (int* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (int* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- float aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ float aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -63171,18 +63941,22 @@ public static double[][] DivideByDiagonal(this float[][] a, int[] diagonal, doub
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this float[] a, int[] b, double[,] result)
+ public static double[,] Outer(this float[] a, int[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -63345,25 +64119,28 @@ public static double[][] Kronecker(this float[][] a, int[][] b, double[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this float[][] a, int[,] b, double[][] result)
+ public static double[][] Kronecker(this float[][] a, int[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -63417,18 +64194,22 @@ public static double[][] Kronecker(this float[,] a, int[][] b, double[][] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this float[] a, int[] b, double[] result)
+ public static double[] Kronecker(this float[] a, int[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -63622,7 +64403,7 @@ public static long[][] Dot(this long[][] a, long[,] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Dot(this long[,] a, long[][] b, long[][] result)
+ public static long[][] Dot(this long[,] a, long[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -63636,21 +64417,24 @@ public static unsafe long[][] Dot(this long[,] a, long[][] b, long[][] result)
var t = new long[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- long s = (long)0;
- for (int k = 0; k < t.Length; k++)
- s += (long)((long)(*pa++) * (long)t[k]);
- result[i][j] = (long)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ long s = (long)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (long)((long)(*pa++) * (long)t[k]);
+ result[i][j] = (long)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -63728,7 +64512,7 @@ public static long[] Dot(this long[][] matrix, long[] columnVector, long[] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Dot(this long[,] matrix, long[] columnVector, long[] result)
+ public static long[] Dot(this long[,] matrix, long[] columnVector, long[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -63737,55 +64521,54 @@ public static unsafe long[] Dot(this long[,] matrix, long[] columnVector, long[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (long* x = columnVector)
+ fixed (long* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- fixed (long* a = matrix)
- fixed (long* x = columnVector)
- fixed (long* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- long sum1 = 0, sum2 = 0;
- long* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (long)((long)(*pa1++) * (long)(*px));
- sum2 += (long)((long)(*pa2++) * (long)(*px));
- px++;
- }
-
- *pr++ = (long)sum1;
- *pr++ = (long)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ long sum1 = 0, sum2 = 0;
+ long* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (long)((long)(*pa1++) * (long)(*px));
+ sum2 += (long)((long)(*pa2++) * (long)(*px));
+ px++;
+ }
+
+ *pr++ = (long)sum1;
+ *pr++ = (long)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- long sum = 0;
- long* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ long sum = 0;
+ long* px = x;
- for (int j = 0; j < cols; j++)
- sum += (long)((long)(*pa1++) * (long)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (long)((long)(*pa1++) * (long)(*px++));
- *pr = (long)sum;
- }
- }
+ *pr = (long)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -63891,7 +64674,7 @@ public static long[] Dot(this long[] rowVector, long[][] matrix, long[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[][] a, long[,] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[][] a, long[,] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -63901,19 +64684,22 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, long[,] b, long
#endif
int n = b.Rows();
- fixed (long* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- long* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- long sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (long)((long)arow[k] * (long)(*pb++));
- result[i][j] = (long)sum;
- }
- }
+ unsafe
+ {
+ fixed (long* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ long* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ long sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (long)((long)arow[k] * (long)(*pb++));
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -63935,7 +64721,7 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, long[,] b, long
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[,] a, long[][] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[,] a, long[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -63945,20 +64731,22 @@ public static unsafe long[][] DotWithTransposed(this long[,] a, long[][] b, long
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- long sum = 0;
- long[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (long)((long)(*pa++) * (long)brow[k]);
- result[i][j] = (long)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ long sum = 0;
+ long[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (long)((long)(*pa++) * (long)brow[k]);
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -64104,7 +64892,7 @@ public static long[][] DotWithTransposed(this long[][] a, long[] columnVector, l
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] TransposeAndDot(this long[,] a, long[,] b, long[,] result)
+ public static long[,] TransposeAndDot(this long[,] a, long[,] b, long[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -64115,35 +64903,37 @@ public static long[][] DotWithTransposed(this long[][] a, long[] columnVector, l
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (long* R = result)
+ fixed (long* B = b)
+ fixed (long* ptemp = new long[p])
+ {
+ long* pr = R;
- fixed (long* R = result)
- fixed (long* B = b)
- fixed (long* ptemp = new long[p])
- {
- long* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- long* pt = ptemp;
- long* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (long)((long)aval * (long)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (long)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ long* pt = ptemp;
+ long* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (long)((long)aval * (long)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (long)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -64537,18 +65327,22 @@ public static long[][] DivideByDiagonal(this long[][] a, long[] diagonal, long[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] Outer(this long[] a, long[] b, long[,] result)
+ public static long[,] Outer(this long[] a, long[] b, long[,] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- long x = (long)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (long)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ long x = (long)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (long)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -64711,25 +65505,28 @@ public static long[][] Kronecker(this long[][] a, long[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Kronecker(this long[][] a, long[,] b, long[][] result)
+ public static long[][] Kronecker(this long[][] a, long[,] b, long[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (long* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- long aval = (long)a[i][j];
- long* pb = B;
+ unsafe
+ {
+ fixed (long* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ long aval = (long)a[i][j];
+ long* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (long)(aval * (long)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (long)(aval * (long)(*pb++));
+ }
+ }
+
return result;
}
@@ -64783,18 +65580,22 @@ public static long[][] Kronecker(this long[,] a, long[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Kronecker(this long[] a, long[] b, long[] result)
+ public static long[] Kronecker(this long[] a, long[] b, long[] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- long x = (long)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (long)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ long x = (long)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (long)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -64988,7 +65789,7 @@ public static double[][] Dot(this long[][] a, long[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this long[,] a, long[][] b, double[][] result)
+ public static double[][] Dot(this long[,] a, long[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -65002,21 +65803,24 @@ public static unsafe double[][] Dot(this long[,] a, long[][] b, double[][] resul
var t = new long[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -65094,7 +65898,7 @@ public static double[] Dot(this long[][] matrix, long[] columnVector, double[] r
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this long[,] matrix, long[] columnVector, double[] result)
+ public static double[] Dot(this long[,] matrix, long[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -65103,55 +65907,54 @@ public static unsafe double[] Dot(this long[,] matrix, long[] columnVector, doub
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (long* x = columnVector)
+ fixed (double* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ double* pr = r;
- fixed (long* a = matrix)
- fixed (long* x = columnVector)
- fixed (double* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- long* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ long* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- long* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ long* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -65257,7 +66060,7 @@ public static double[] Dot(this long[] rowVector, long[][] matrix, double[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[][] a, long[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[][] a, long[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -65267,19 +66070,22 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, long[,] b, do
#endif
int n = b.Rows();
- fixed (long* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- long* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (long* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ long* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -65301,7 +66107,7 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, long[,] b, do
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[,] a, long[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[,] a, long[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -65311,20 +66117,22 @@ public static unsafe double[][] DotWithTransposed(this long[,] a, long[][] b, do
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- long[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ long[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -65470,7 +66278,7 @@ public static double[][] DotWithTransposed(this long[][] a, long[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this long[,] a, long[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this long[,] a, long[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -65481,35 +66289,37 @@ public static double[][] DotWithTransposed(this long[][] a, long[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (long* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (long* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- long* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ long* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -65903,18 +66713,22 @@ public static double[][] DivideByDiagonal(this long[][] a, long[] diagonal, doub
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this long[] a, long[] b, double[,] result)
+ public static double[,] Outer(this long[] a, long[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -66077,25 +66891,28 @@ public static double[][] Kronecker(this long[][] a, long[][] b, double[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this long[][] a, long[,] b, double[][] result)
+ public static double[][] Kronecker(this long[][] a, long[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (long* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- long* pb = B;
+ unsafe
+ {
+ fixed (long* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ long* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -66149,18 +66966,22 @@ public static double[][] Kronecker(this long[,] a, long[][] b, double[][] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this long[] a, long[] b, double[] result)
+ public static double[] Kronecker(this long[] a, long[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -66354,7 +67175,7 @@ public static int[][] Dot(this long[][] a, long[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this long[,] a, long[][] b, int[][] result)
+ public static int[][] Dot(this long[,] a, long[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -66368,21 +67189,24 @@ public static unsafe int[][] Dot(this long[,] a, long[][] b, int[][] result)
var t = new long[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -66460,7 +67284,7 @@ public static int[] Dot(this long[][] matrix, long[] columnVector, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this long[,] matrix, long[] columnVector, int[] result)
+ public static int[] Dot(this long[,] matrix, long[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -66469,55 +67293,54 @@ public static unsafe int[] Dot(this long[,] matrix, long[] columnVector, int[] r
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (long* x = columnVector)
+ fixed (int* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ int* pr = r;
- fixed (long* a = matrix)
- fixed (long* x = columnVector)
- fixed (int* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- long* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ long* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- long* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ long* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -66623,7 +67446,7 @@ public static int[] Dot(this long[] rowVector, long[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[][] a, long[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[][] a, long[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -66633,19 +67456,22 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, long[,] b, int[]
#endif
int n = b.Rows();
- fixed (long* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- long* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (long* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ long* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -66667,7 +67493,7 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, long[,] b, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[,] a, long[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[,] a, long[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -66677,20 +67503,22 @@ public static unsafe int[][] DotWithTransposed(this long[,] a, long[][] b, int[]
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- long[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ long[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -66836,7 +67664,7 @@ public static int[][] DotWithTransposed(this long[][] a, long[] columnVector, in
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this long[,] a, long[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this long[,] a, long[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -66847,35 +67675,37 @@ public static int[][] DotWithTransposed(this long[][] a, long[] columnVector, in
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (long* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (long* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- long* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ long* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -67269,18 +68099,22 @@ public static int[][] DivideByDiagonal(this long[][] a, long[] diagonal, int[][]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this long[] a, long[] b, int[,] result)
+ public static int[,] Outer(this long[] a, long[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -67443,25 +68277,28 @@ public static int[][] Kronecker(this long[][] a, long[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this long[][] a, long[,] b, int[][] result)
+ public static int[][] Kronecker(this long[][] a, long[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (long* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- long* pb = B;
+ unsafe
+ {
+ fixed (long* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ long* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -67515,18 +68352,22 @@ public static int[][] Kronecker(this long[,] a, long[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this long[] a, long[] b, int[] result)
+ public static int[] Kronecker(this long[] a, long[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -67720,7 +68561,7 @@ public static long[][] Dot(this long[][] a, double[,] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Dot(this long[,] a, double[][] b, long[][] result)
+ public static long[][] Dot(this long[,] a, double[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -67734,21 +68575,24 @@ public static unsafe long[][] Dot(this long[,] a, double[][] b, long[][] result)
var t = new double[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- long s = (long)0;
- for (int k = 0; k < t.Length; k++)
- s += (long)((long)(*pa++) * (long)t[k]);
- result[i][j] = (long)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ long s = (long)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (long)((long)(*pa++) * (long)t[k]);
+ result[i][j] = (long)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -67826,7 +68670,7 @@ public static long[] Dot(this long[][] matrix, double[] columnVector, long[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Dot(this long[,] matrix, double[] columnVector, long[] result)
+ public static long[] Dot(this long[,] matrix, double[] columnVector, long[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -67835,55 +68679,54 @@ public static unsafe long[] Dot(this long[,] matrix, double[] columnVector, long
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (long* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- fixed (long* a = matrix)
- fixed (double* x = columnVector)
- fixed (long* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- long sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (long)((long)(*pa1++) * (long)(*px));
- sum2 += (long)((long)(*pa2++) * (long)(*px));
- px++;
- }
-
- *pr++ = (long)sum1;
- *pr++ = (long)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ long sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (long)((long)(*pa1++) * (long)(*px));
+ sum2 += (long)((long)(*pa2++) * (long)(*px));
+ px++;
+ }
+
+ *pr++ = (long)sum1;
+ *pr++ = (long)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- long sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ long sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (long)((long)(*pa1++) * (long)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (long)((long)(*pa1++) * (long)(*px++));
- *pr = (long)sum;
- }
- }
+ *pr = (long)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -67989,7 +68832,7 @@ public static long[] Dot(this long[] rowVector, double[][] matrix, long[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[][] a, double[,] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[][] a, double[,] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -67999,19 +68842,22 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, double[,] b, lo
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- long sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (long)((long)arow[k] * (long)(*pb++));
- result[i][j] = (long)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ long sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (long)((long)arow[k] * (long)(*pb++));
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -68033,7 +68879,7 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, double[,] b, lo
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[,] a, double[][] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[,] a, double[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -68043,20 +68889,22 @@ public static unsafe long[][] DotWithTransposed(this long[,] a, double[][] b, lo
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- long sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (long)((long)(*pa++) * (long)brow[k]);
- result[i][j] = (long)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ long sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (long)((long)(*pa++) * (long)brow[k]);
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -68202,7 +69050,7 @@ public static long[][] DotWithTransposed(this long[][] a, double[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] TransposeAndDot(this long[,] a, double[,] b, long[,] result)
+ public static long[,] TransposeAndDot(this long[,] a, double[,] b, long[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -68213,35 +69061,37 @@ public static long[][] DotWithTransposed(this long[][] a, double[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (long* R = result)
+ fixed (double* B = b)
+ fixed (long* ptemp = new long[p])
+ {
+ long* pr = R;
- fixed (long* R = result)
- fixed (double* B = b)
- fixed (long* ptemp = new long[p])
- {
- long* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- long* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (long)((long)aval * (long)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (long)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ long* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (long)((long)aval * (long)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (long)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -68635,18 +69485,22 @@ public static long[][] DivideByDiagonal(this long[][] a, double[] diagonal, long
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] Outer(this long[] a, double[] b, long[,] result)
+ public static long[,] Outer(this long[] a, double[] b, long[,] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- long x = (long)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (long)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ long x = (long)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (long)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -68809,25 +69663,28 @@ public static long[][] Kronecker(this long[][] a, double[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Kronecker(this long[][] a, double[,] b, long[][] result)
+ public static long[][] Kronecker(this long[][] a, double[,] b, long[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- long aval = (long)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ long aval = (long)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (long)(aval * (long)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (long)(aval * (long)(*pb++));
+ }
+ }
+
return result;
}
@@ -68881,18 +69738,22 @@ public static long[][] Kronecker(this long[,] a, double[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Kronecker(this long[] a, double[] b, long[] result)
+ public static long[] Kronecker(this long[] a, double[] b, long[] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- long x = (long)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (long)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ long x = (long)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (long)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -69086,7 +69947,7 @@ public static double[][] Dot(this long[][] a, double[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this long[,] a, double[][] b, double[][] result)
+ public static double[][] Dot(this long[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -69100,21 +69961,24 @@ public static unsafe double[][] Dot(this long[,] a, double[][] b, double[][] res
var t = new double[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -69192,7 +70056,7 @@ public static double[] Dot(this long[][] matrix, double[] columnVector, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this long[,] matrix, double[] columnVector, double[] result)
+ public static double[] Dot(this long[,] matrix, double[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -69201,55 +70065,54 @@ public static unsafe double[] Dot(this long[,] matrix, double[] columnVector, do
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (double* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ double* pr = r;
- fixed (long* a = matrix)
- fixed (double* x = columnVector)
- fixed (double* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -69355,7 +70218,7 @@ public static double[] Dot(this long[] rowVector, double[][] matrix, double[] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[][] a, double[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[][] a, double[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -69365,19 +70228,22 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, double[,] b,
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -69399,7 +70265,7 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, double[,] b,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[,] a, double[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[,] a, double[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -69409,20 +70275,22 @@ public static unsafe double[][] DotWithTransposed(this long[,] a, double[][] b,
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -69568,7 +70436,7 @@ public static double[][] DotWithTransposed(this long[][] a, double[] columnVecto
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this long[,] a, double[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this long[,] a, double[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -69579,35 +70447,37 @@ public static double[][] DotWithTransposed(this long[][] a, double[] columnVecto
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (double* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (double* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -70001,18 +70871,22 @@ public static double[][] DivideByDiagonal(this long[][] a, double[] diagonal, do
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this long[] a, double[] b, double[,] result)
+ public static double[,] Outer(this long[] a, double[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -70175,25 +71049,28 @@ public static double[][] Kronecker(this long[][] a, double[][] b, double[][] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this long[][] a, double[,] b, double[][] result)
+ public static double[][] Kronecker(this long[][] a, double[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -70247,18 +71124,22 @@ public static double[][] Kronecker(this long[,] a, double[][] b, double[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this long[] a, double[] b, double[] result)
+ public static double[] Kronecker(this long[] a, double[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -70452,7 +71333,7 @@ public static int[][] Dot(this long[][] a, double[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this long[,] a, double[][] b, int[][] result)
+ public static int[][] Dot(this long[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -70466,21 +71347,24 @@ public static unsafe int[][] Dot(this long[,] a, double[][] b, int[][] result)
var t = new double[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -70558,7 +71442,7 @@ public static int[] Dot(this long[][] matrix, double[] columnVector, int[] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this long[,] matrix, double[] columnVector, int[] result)
+ public static int[] Dot(this long[,] matrix, double[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -70567,55 +71451,54 @@ public static unsafe int[] Dot(this long[,] matrix, double[] columnVector, int[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (double* x = columnVector)
+ fixed (int* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ int* pr = r;
- fixed (long* a = matrix)
- fixed (double* x = columnVector)
- fixed (int* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- double* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ double* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- double* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ double* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -70721,7 +71604,7 @@ public static int[] Dot(this long[] rowVector, double[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[][] a, double[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[][] a, double[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -70731,19 +71614,22 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, double[,] b, int
#endif
int n = b.Rows();
- fixed (double* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- double* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ double* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -70765,7 +71651,7 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, double[,] b, int
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[,] a, double[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[,] a, double[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -70775,20 +71661,22 @@ public static unsafe int[][] DotWithTransposed(this long[,] a, double[][] b, int
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- double[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ double[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -70934,7 +71822,7 @@ public static int[][] DotWithTransposed(this long[][] a, double[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this long[,] a, double[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this long[,] a, double[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -70945,35 +71833,37 @@ public static int[][] DotWithTransposed(this long[][] a, double[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (double* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (double* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- double* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ double* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -71367,18 +72257,22 @@ public static int[][] DivideByDiagonal(this long[][] a, double[] diagonal, int[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this long[] a, double[] b, int[,] result)
+ public static int[,] Outer(this long[] a, double[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -71541,25 +72435,28 @@ public static int[][] Kronecker(this long[][] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this long[][] a, double[,] b, int[][] result)
+ public static int[][] Kronecker(this long[][] a, double[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (double* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- double* pb = B;
+ unsafe
+ {
+ fixed (double* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ double* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -71613,18 +72510,22 @@ public static int[][] Kronecker(this long[,] a, double[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this long[] a, double[] b, int[] result)
+ public static int[] Kronecker(this long[] a, double[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -71818,7 +72719,7 @@ public static long[][] Dot(this long[][] a, int[,] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Dot(this long[,] a, int[][] b, long[][] result)
+ public static long[][] Dot(this long[,] a, int[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -71832,21 +72733,24 @@ public static unsafe long[][] Dot(this long[,] a, int[][] b, long[][] result)
var t = new int[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- long s = (long)0;
- for (int k = 0; k < t.Length; k++)
- s += (long)((long)(*pa++) * (long)t[k]);
- result[i][j] = (long)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ long s = (long)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (long)((long)(*pa++) * (long)t[k]);
+ result[i][j] = (long)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -71924,7 +72828,7 @@ public static long[] Dot(this long[][] matrix, int[] columnVector, long[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Dot(this long[,] matrix, int[] columnVector, long[] result)
+ public static long[] Dot(this long[,] matrix, int[] columnVector, long[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -71933,55 +72837,54 @@ public static unsafe long[] Dot(this long[,] matrix, int[] columnVector, long[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (long* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- fixed (long* a = matrix)
- fixed (int* x = columnVector)
- fixed (long* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- long sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (long)((long)(*pa1++) * (long)(*px));
- sum2 += (long)((long)(*pa2++) * (long)(*px));
- px++;
- }
-
- *pr++ = (long)sum1;
- *pr++ = (long)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ long sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (long)((long)(*pa1++) * (long)(*px));
+ sum2 += (long)((long)(*pa2++) * (long)(*px));
+ px++;
+ }
+
+ *pr++ = (long)sum1;
+ *pr++ = (long)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- long sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ long sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (long)((long)(*pa1++) * (long)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (long)((long)(*pa1++) * (long)(*px++));
- *pr = (long)sum;
- }
- }
+ *pr = (long)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -72087,7 +72990,7 @@ public static long[] Dot(this long[] rowVector, int[][] matrix, long[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[][] a, int[,] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[][] a, int[,] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -72097,19 +73000,22 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, int[,] b, long[
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- long sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (long)((long)arow[k] * (long)(*pb++));
- result[i][j] = (long)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ long sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (long)((long)arow[k] * (long)(*pb++));
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -72131,7 +73037,7 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, int[,] b, long[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[,] a, int[][] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[,] a, int[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -72141,20 +73047,22 @@ public static unsafe long[][] DotWithTransposed(this long[,] a, int[][] b, long[
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- long sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (long)((long)(*pa++) * (long)brow[k]);
- result[i][j] = (long)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ long sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (long)((long)(*pa++) * (long)brow[k]);
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -72300,7 +73208,7 @@ public static long[][] DotWithTransposed(this long[][] a, int[] columnVector, lo
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] TransposeAndDot(this long[,] a, int[,] b, long[,] result)
+ public static long[,] TransposeAndDot(this long[,] a, int[,] b, long[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -72311,35 +73219,37 @@ public static long[][] DotWithTransposed(this long[][] a, int[] columnVector, lo
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (long* R = result)
+ fixed (int* B = b)
+ fixed (long* ptemp = new long[p])
+ {
+ long* pr = R;
- fixed (long* R = result)
- fixed (int* B = b)
- fixed (long* ptemp = new long[p])
- {
- long* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- long* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (long)((long)aval * (long)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (long)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ long* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (long)((long)aval * (long)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (long)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -72733,18 +73643,22 @@ public static long[][] DivideByDiagonal(this long[][] a, int[] diagonal, long[][
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] Outer(this long[] a, int[] b, long[,] result)
+ public static long[,] Outer(this long[] a, int[] b, long[,] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- long x = (long)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (long)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ long x = (long)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (long)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -72907,25 +73821,28 @@ public static long[][] Kronecker(this long[][] a, int[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Kronecker(this long[][] a, int[,] b, long[][] result)
+ public static long[][] Kronecker(this long[][] a, int[,] b, long[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- long aval = (long)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ long aval = (long)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (long)(aval * (long)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (long)(aval * (long)(*pb++));
+ }
+ }
+
return result;
}
@@ -72979,18 +73896,22 @@ public static long[][] Kronecker(this long[,] a, int[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Kronecker(this long[] a, int[] b, long[] result)
+ public static long[] Kronecker(this long[] a, int[] b, long[] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- long x = (long)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (long)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ long x = (long)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (long)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -73184,7 +74105,7 @@ public static int[][] Dot(this long[][] a, int[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this long[,] a, int[][] b, int[][] result)
+ public static int[][] Dot(this long[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -73198,21 +74119,24 @@ public static unsafe int[][] Dot(this long[,] a, int[][] b, int[][] result)
var t = new int[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- int s = (int)0;
- for (int k = 0; k < t.Length; k++)
- s += (int)((int)(*pa++) * (int)t[k]);
- result[i][j] = (int)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ int s = (int)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (int)((int)(*pa++) * (int)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -73290,7 +74214,7 @@ public static int[] Dot(this long[][] matrix, int[] columnVector, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this long[,] matrix, int[] columnVector, int[] result)
+ public static int[] Dot(this long[,] matrix, int[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -73299,55 +74223,54 @@ public static unsafe int[] Dot(this long[,] matrix, int[] columnVector, int[] re
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (int* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ int* pr = r;
- fixed (long* a = matrix)
- fixed (int* x = columnVector)
- fixed (int* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- int sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (int)((int)(*pa1++) * (int)(*px));
- sum2 += (int)((int)(*pa2++) * (int)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ int sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (int)((int)(*pa1++) * (int)(*px));
+ sum2 += (int)((int)(*pa2++) * (int)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- int sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ int sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (int)((int)(*pa1++) * (int)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (int)((int)(*pa1++) * (int)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -73453,7 +74376,7 @@ public static int[] Dot(this long[] rowVector, int[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[][] a, int[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[][] a, int[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -73463,19 +74386,22 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, int[,] b, int[][
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- int sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (int)((int)arow[k] * (int)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ int sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (int)((int)arow[k] * (int)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -73497,7 +74423,7 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, int[,] b, int[][
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[,] a, int[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[,] a, int[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -73507,20 +74433,22 @@ public static unsafe int[][] DotWithTransposed(this long[,] a, int[][] b, int[][
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- int sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (int)((int)(*pa++) * (int)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ int sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (int)((int)(*pa++) * (int)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -73666,7 +74594,7 @@ public static int[][] DotWithTransposed(this long[][] a, int[] columnVector, int
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this long[,] a, int[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this long[,] a, int[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -73677,35 +74605,37 @@ public static int[][] DotWithTransposed(this long[][] a, int[] columnVector, int
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (int* B = b)
+ fixed (int* ptemp = new int[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (int* B = b)
- fixed (int* ptemp = new int[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- int* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (int)((int)aval * (int)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ int* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (int)((int)aval * (int)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -74099,18 +75029,22 @@ public static int[][] DivideByDiagonal(this long[][] a, int[] diagonal, int[][]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this long[] a, int[] b, int[,] result)
+ public static int[,] Outer(this long[] a, int[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -74273,25 +75207,28 @@ public static int[][] Kronecker(this long[][] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this long[][] a, int[,] b, int[][] result)
+ public static int[][] Kronecker(this long[][] a, int[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- int aval = (int)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ int aval = (int)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (int)(*pb++));
+ }
+ }
+
return result;
}
@@ -74345,18 +75282,22 @@ public static int[][] Kronecker(this long[,] a, int[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this long[] a, int[] b, int[] result)
+ public static int[] Kronecker(this long[] a, int[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- int x = (int)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (int)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ int x = (int)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (int)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -74550,7 +75491,7 @@ public static double[][] Dot(this long[][] a, int[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this long[,] a, int[][] b, double[][] result)
+ public static double[][] Dot(this long[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -74564,21 +75505,24 @@ public static unsafe double[][] Dot(this long[,] a, int[][] b, double[][] result
var t = new int[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -74656,7 +75600,7 @@ public static double[] Dot(this long[][] matrix, int[] columnVector, double[] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this long[,] matrix, int[] columnVector, double[] result)
+ public static double[] Dot(this long[,] matrix, int[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -74665,55 +75609,54 @@ public static unsafe double[] Dot(this long[,] matrix, int[] columnVector, doubl
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (int* x = columnVector)
+ fixed (double* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ double* pr = r;
- fixed (long* a = matrix)
- fixed (int* x = columnVector)
- fixed (double* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- int* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ int* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- int* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ int* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -74819,7 +75762,7 @@ public static double[] Dot(this long[] rowVector, int[][] matrix, double[] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[][] a, int[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[][] a, int[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -74829,19 +75772,22 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, int[,] b, dou
#endif
int n = b.Rows();
- fixed (int* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- int* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ int* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -74863,7 +75809,7 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, int[,] b, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[,] a, int[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[,] a, int[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -74873,20 +75819,22 @@ public static unsafe double[][] DotWithTransposed(this long[,] a, int[][] b, dou
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- int[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ int[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -75032,7 +75980,7 @@ public static double[][] DotWithTransposed(this long[][] a, int[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this long[,] a, int[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this long[,] a, int[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -75043,35 +75991,37 @@ public static double[][] DotWithTransposed(this long[][] a, int[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (int* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (int* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- int* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ int* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -75465,18 +76415,22 @@ public static double[][] DivideByDiagonal(this long[][] a, int[] diagonal, doubl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this long[] a, int[] b, double[,] result)
+ public static double[,] Outer(this long[] a, int[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -75639,25 +76593,28 @@ public static double[][] Kronecker(this long[][] a, int[][] b, double[][] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this long[][] a, int[,] b, double[][] result)
+ public static double[][] Kronecker(this long[][] a, int[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (int* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- int* pb = B;
+ unsafe
+ {
+ fixed (int* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ int* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -75711,18 +76668,22 @@ public static double[][] Kronecker(this long[,] a, int[][] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this long[] a, int[] b, double[] result)
+ public static double[] Kronecker(this long[] a, int[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -75916,7 +76877,7 @@ public static long[][] Dot(this long[][] a, float[,] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Dot(this long[,] a, float[][] b, long[][] result)
+ public static long[][] Dot(this long[,] a, float[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -75930,21 +76891,24 @@ public static unsafe long[][] Dot(this long[,] a, float[][] b, long[][] result)
var t = new float[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (long)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (long)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -76022,7 +76986,7 @@ public static long[] Dot(this long[][] matrix, float[] columnVector, long[] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Dot(this long[,] matrix, float[] columnVector, long[] result)
+ public static long[] Dot(this long[,] matrix, float[] columnVector, long[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -76031,55 +76995,54 @@ public static unsafe long[] Dot(this long[,] matrix, float[] columnVector, long[
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (long* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ long* pr = r;
- fixed (long* a = matrix)
- fixed (float* x = columnVector)
- fixed (long* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- long* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (long)sum1;
- *pr++ = (long)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (long)sum1;
+ *pr++ = (long)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (long)sum;
- }
- }
+ *pr = (long)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -76185,7 +77148,7 @@ public static long[] Dot(this long[] rowVector, float[][] matrix, long[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[][] a, float[,] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[][] a, float[,] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -76195,19 +77158,22 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, float[,] b, lon
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (long)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -76229,7 +77195,7 @@ public static unsafe long[][] DotWithTransposed(this long[][] a, float[,] b, lon
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] DotWithTransposed(this long[,] a, float[][] b, long[][] result)
+ public static long[][] DotWithTransposed(this long[,] a, float[][] b, long[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -76239,20 +77205,22 @@ public static unsafe long[][] DotWithTransposed(this long[,] a, float[][] b, lon
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (long)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (long)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -76398,7 +77366,7 @@ public static long[][] DotWithTransposed(this long[][] a, float[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] TransposeAndDot(this long[,] a, float[,] b, long[,] result)
+ public static long[,] TransposeAndDot(this long[,] a, float[,] b, long[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -76409,35 +77377,37 @@ public static long[][] DotWithTransposed(this long[][] a, float[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (long* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ long* pr = R;
- fixed (long* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- long* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (long)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (long)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -76831,18 +77801,22 @@ public static long[][] DivideByDiagonal(this long[][] a, float[] diagonal, long[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[,] Outer(this long[] a, float[] b, long[,] result)
+ public static long[,] Outer(this long[] a, float[] b, long[,] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -77005,25 +77979,28 @@ public static long[][] Kronecker(this long[][] a, float[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[][] Kronecker(this long[][] a, float[,] b, long[][] result)
+ public static long[][] Kronecker(this long[][] a, float[,] b, long[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (long)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (long)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -77077,18 +78054,22 @@ public static long[][] Kronecker(this long[,] a, float[][] b, long[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe long[] Kronecker(this long[] a, float[] b, long[] result)
+ public static long[] Kronecker(this long[] a, float[] b, long[] result)
{
- fixed (long* R = result)
- {
- long* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (long)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (long* R = result)
+ {
+ long* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (long)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -77282,7 +78263,7 @@ public static float[][] Dot(this long[][] a, float[,] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Dot(this long[,] a, float[][] b, float[][] result)
+ public static float[][] Dot(this long[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -77296,21 +78277,24 @@ public static unsafe float[][] Dot(this long[,] a, float[][] b, float[][] result
var t = new float[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (float)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (float)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -77388,7 +78372,7 @@ public static float[] Dot(this long[][] matrix, float[] columnVector, float[] re
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Dot(this long[,] matrix, float[] columnVector, float[] result)
+ public static float[] Dot(this long[,] matrix, float[] columnVector, float[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -77397,55 +78381,54 @@ public static unsafe float[] Dot(this long[,] matrix, float[] columnVector, floa
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (float* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ float* pr = r;
- fixed (long* a = matrix)
- fixed (float* x = columnVector)
- fixed (float* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- float* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (float)sum1;
- *pr++ = (float)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (float)sum1;
+ *pr++ = (float)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (float)sum;
- }
- }
+ *pr = (float)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -77551,7 +78534,7 @@ public static float[] Dot(this long[] rowVector, float[][] matrix, float[] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this long[][] a, float[,] b, float[][] result)
+ public static float[][] DotWithTransposed(this long[][] a, float[,] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -77561,19 +78544,22 @@ public static unsafe float[][] DotWithTransposed(this long[][] a, float[,] b, fl
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (float)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -77595,7 +78581,7 @@ public static unsafe float[][] DotWithTransposed(this long[][] a, float[,] b, fl
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] DotWithTransposed(this long[,] a, float[][] b, float[][] result)
+ public static float[][] DotWithTransposed(this long[,] a, float[][] b, float[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -77605,20 +78591,22 @@ public static unsafe float[][] DotWithTransposed(this long[,] a, float[][] b, fl
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (float)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (float)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -77764,7 +78752,7 @@ public static float[][] DotWithTransposed(this long[][] a, float[] columnVector,
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] TransposeAndDot(this long[,] a, float[,] b, float[,] result)
+ public static float[,] TransposeAndDot(this long[,] a, float[,] b, float[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -77775,35 +78763,37 @@ public static float[][] DotWithTransposed(this long[][] a, float[] columnVector,
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (float* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ float* pr = R;
- fixed (float* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- float* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (float)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (float)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -78197,18 +79187,22 @@ public static float[][] DivideByDiagonal(this long[][] a, float[] diagonal, floa
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[,] Outer(this long[] a, float[] b, float[,] result)
+ public static float[,] Outer(this long[] a, float[] b, float[,] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -78371,25 +79365,28 @@ public static float[][] Kronecker(this long[][] a, float[][] b, float[][] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[][] Kronecker(this long[][] a, float[,] b, float[][] result)
+ public static float[][] Kronecker(this long[][] a, float[,] b, float[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (float)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -78443,18 +79440,22 @@ public static float[][] Kronecker(this long[,] a, float[][] b, float[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe float[] Kronecker(this long[] a, float[] b, float[] result)
+ public static float[] Kronecker(this long[] a, float[] b, float[] result)
{
- fixed (float* R = result)
- {
- float* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (float)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (float* R = result)
+ {
+ float* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (float)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -78648,7 +79649,7 @@ public static double[][] Dot(this long[][] a, float[,] b, double[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Dot(this long[,] a, float[][] b, double[][] result)
+ public static double[][] Dot(this long[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -78662,21 +79663,24 @@ public static unsafe double[][] Dot(this long[,] a, float[][] b, double[][] resu
var t = new float[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (double)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (double)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -78754,7 +79758,7 @@ public static double[] Dot(this long[][] matrix, float[] columnVector, double[]
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Dot(this long[,] matrix, float[] columnVector, double[] result)
+ public static double[] Dot(this long[,] matrix, float[] columnVector, double[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -78763,55 +79767,54 @@ public static unsafe double[] Dot(this long[,] matrix, float[] columnVector, dou
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (double* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ double* pr = r;
- fixed (long* a = matrix)
- fixed (float* x = columnVector)
- fixed (double* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- double* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (double)sum1;
- *pr++ = (double)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (double)sum1;
+ *pr++ = (double)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (double)sum;
- }
- }
+ *pr = (double)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -78917,7 +79920,7 @@ public static double[] Dot(this long[] rowVector, float[][] matrix, double[] res
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[][] a, float[,] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[][] a, float[,] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -78927,19 +79930,22 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, float[,] b, d
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (double)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -78961,7 +79967,7 @@ public static unsafe double[][] DotWithTransposed(this long[][] a, float[,] b, d
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] DotWithTransposed(this long[,] a, float[][] b, double[][] result)
+ public static double[][] DotWithTransposed(this long[,] a, float[][] b, double[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -78971,20 +79977,22 @@ public static unsafe double[][] DotWithTransposed(this long[,] a, float[][] b, d
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (double)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (double)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -79130,7 +80138,7 @@ public static double[][] DotWithTransposed(this long[][] a, float[] columnVector
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] TransposeAndDot(this long[,] a, float[,] b, double[,] result)
+ public static double[,] TransposeAndDot(this long[,] a, float[,] b, double[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -79141,35 +80149,37 @@ public static double[][] DotWithTransposed(this long[][] a, float[] columnVector
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (double* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ double* pr = R;
- fixed (double* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- double* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (double)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (double)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -79563,18 +80573,22 @@ public static double[][] DivideByDiagonal(this long[][] a, float[] diagonal, dou
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[,] Outer(this long[] a, float[] b, double[,] result)
+ public static double[,] Outer(this long[] a, float[] b, double[,] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -79737,25 +80751,28 @@ public static double[][] Kronecker(this long[][] a, float[][] b, double[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[][] Kronecker(this long[][] a, float[,] b, double[][] result)
+ public static double[][] Kronecker(this long[][] a, float[,] b, double[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (double)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -79809,18 +80826,22 @@ public static double[][] Kronecker(this long[,] a, float[][] b, double[][] resul
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe double[] Kronecker(this long[] a, float[] b, double[] result)
+ public static double[] Kronecker(this long[] a, float[] b, double[] result)
{
- fixed (double* R = result)
- {
- double* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (double)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (double* R = result)
+ {
+ double* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (double)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -80014,7 +81035,7 @@ public static int[][] Dot(this long[][] a, float[,] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Dot(this long[,] a, float[][] b, int[][] result)
+ public static int[][] Dot(this long[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -80028,21 +81049,24 @@ public static unsafe int[][] Dot(this long[,] a, float[][] b, int[][] result)
var t = new float[K];
- fixed (long* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- long* pa = A;
- for (int i = 0; i < N; i++)
- {
- double s = (double)0;
- for (int k = 0; k < t.Length; k++)
- s += (double)((double)(*pa++) * (double)t[k]);
- result[i][j] = (int)s;
- }
- }
+ long* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ double s = (double)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (double)((double)(*pa++) * (double)t[k]);
+ result[i][j] = (int)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -80120,7 +81144,7 @@ public static int[] Dot(this long[][] matrix, float[] columnVector, int[] result
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Dot(this long[,] matrix, float[] columnVector, int[] result)
+ public static int[] Dot(this long[,] matrix, float[] columnVector, int[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -80129,55 +81153,54 @@ public static unsafe int[] Dot(this long[,] matrix, float[] columnVector, int[]
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (long* a = matrix)
+ fixed (float* x = columnVector)
+ fixed (int* r = result)
+ {
+ long* pa1 = a;
+ long* pa2 = a + cols;
+ int* pr = r;
- fixed (long* a = matrix)
- fixed (float* x = columnVector)
- fixed (int* r = result)
- {
- long* pa1 = a;
- long* pa2 = a + cols;
- int* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- double sum1 = 0, sum2 = 0;
- float* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (double)((double)(*pa1++) * (double)(*px));
- sum2 += (double)((double)(*pa2++) * (double)(*px));
- px++;
- }
-
- *pr++ = (int)sum1;
- *pr++ = (int)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ double sum1 = 0, sum2 = 0;
+ float* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (double)((double)(*pa1++) * (double)(*px));
+ sum2 += (double)((double)(*pa2++) * (double)(*px));
+ px++;
+ }
+
+ *pr++ = (int)sum1;
+ *pr++ = (int)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- double sum = 0;
- float* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ double sum = 0;
+ float* px = x;
- for (int j = 0; j < cols; j++)
- sum += (double)((double)(*pa1++) * (double)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (double)((double)(*pa1++) * (double)(*px++));
- *pr = (int)sum;
- }
- }
+ *pr = (int)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product R = A*B of two matrices A
/// and B, storing the result in matrix R.
@@ -80283,7 +81306,7 @@ public static int[] Dot(this long[] rowVector, float[][] matrix, int[] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[][] a, float[,] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[][] a, float[,] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -80293,19 +81316,22 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, float[,] b, int[
#endif
int n = b.Rows();
- fixed (float* B = b)
- for (int i = 0; i < a.Length; i++)
- {
- float* pb = B;
- long[] arow = a[i];
- for (int j = 0; j < n; j++)
- {
- double sum = 0;
- for (int k = 0; k < arow.Length; k++)
- sum += (double)((double)arow[k] * (double)(*pb++));
- result[i][j] = (int)sum;
- }
- }
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < a.Length; i++)
+ {
+ float* pb = B;
+ long[] arow = a[i];
+ for (int j = 0; j < n; j++)
+ {
+ double sum = 0;
+ for (int k = 0; k < arow.Length; k++)
+ sum += (double)((double)arow[k] * (double)(*pb++));
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -80327,7 +81353,7 @@ public static unsafe int[][] DotWithTransposed(this long[][] a, float[,] b, int[
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] DotWithTransposed(this long[,] a, float[][] b, int[][] result)
+ public static int[][] DotWithTransposed(this long[,] a, float[][] b, int[][] result)
{
#if DEBUG
if (a.Columns() != b.Columns() || result.Rows() > a.Rows() || result.Columns() > b.Rows())
@@ -80337,20 +81363,22 @@ public static unsafe int[][] DotWithTransposed(this long[,] a, float[][] b, int[
#endif
int n = a.Rows();
- fixed (long* A = a)
- for (int j = 0; j < b.Length; j++)
- {
- long* pa = A;
- for (int i = 0; i < n; i++)
- {
- double sum = 0;
- float[] brow = b[j];
- for (int k = 0; k < brow.Length; k++)
- sum += (double)((double)(*pa++) * (double)brow[k]);
- result[i][j] = (int)sum;
- }
- }
-
+ unsafe
+ {
+ fixed (long* A = a)
+ for (int j = 0; j < b.Length; j++)
+ {
+ long* pa = A;
+ for (int i = 0; i < n; i++)
+ {
+ double sum = 0;
+ float[] brow = b[j];
+ for (int k = 0; k < brow.Length; k++)
+ sum += (double)((double)(*pa++) * (double)brow[k]);
+ result[i][j] = (int)sum;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.To(), 1e-4))
throw new Exception();
@@ -80496,7 +81524,7 @@ public static int[][] DotWithTransposed(this long[][] a, float[] columnVector, i
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] TransposeAndDot(this long[,] a, float[,] b, int[,] result)
+ public static int[,] TransposeAndDot(this long[,] a, float[,] b, int[,] result)
{
int n = a.Rows();
int m = a.Columns();
@@ -80507,35 +81535,37 @@ public static int[][] DotWithTransposed(this long[][] a, float[] columnVector, i
throw new DimensionMismatchException();
var C = a.Transpose().To().Dot(b.To());
#endif
+ unsafe
+ {
+ fixed (int* R = result)
+ fixed (float* B = b)
+ fixed (double* ptemp = new double[p])
+ {
+ int* pr = R;
- fixed (int* R = result)
- fixed (float* B = b)
- fixed (double* ptemp = new double[p])
- {
- int* pr = R;
-
- for (int i = 0; i < m; i++)
- {
- double* pt = ptemp;
- float* pb = B;
-
- for (int k = 0; k < n; k++)
- {
- long aval = a[k, i];
- for (int j = 0; j < p; j++)
- *pt++ += (double)((double)aval * (double)(*pb++));
- pt = ptemp;
- }
-
- // Update the results row and clear the cache
- for (int j = 0; j < p; j++)
- {
- *pr++ = (int)*pt;
- *pt++ = 0;
- }
- }
- }
-
+ for (int i = 0; i < m; i++)
+ {
+ double* pt = ptemp;
+ float* pb = B;
+
+ for (int k = 0; k < n; k++)
+ {
+ long aval = a[k, i];
+ for (int j = 0; j < p; j++)
+ *pt++ += (double)((double)aval * (double)(*pb++));
+ pt = ptemp;
+ }
+
+ // Update the results row and clear the cache
+ for (int j = 0; j < p; j++)
+ {
+ *pr++ = (int)*pt;
+ *pt++ = 0;
+ }
+ }
+ }
+ }
+
#if DEBUG
if (!C.IsEqual(result.To(), 1e-4))
throw new Exception();
@@ -80929,18 +81959,22 @@ public static int[][] DivideByDiagonal(this long[][] a, float[] diagonal, int[][
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[,] Outer(this long[] a, float[] b, int[,] result)
+ public static int[,] Outer(this long[] a, float[] b, int[,] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -81103,25 +82137,28 @@ public static int[][] Kronecker(this long[][] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[][] Kronecker(this long[][] a, float[,] b, int[][] result)
+ public static int[][] Kronecker(this long[][] a, float[,] b, int[][] result)
{
int arows = a.Rows();
int acols = a.Columns();
int brows = b.Rows();
int bcols = b.Columns();
- fixed (float* B = b)
- for (int i = 0; i < arows; i++)
- for (int j = 0; j < acols; j++)
- {
- double aval = (double)a[i][j];
- float* pb = B;
+ unsafe
+ {
+ fixed (float* B = b)
+ for (int i = 0; i < arows; i++)
+ for (int j = 0; j < acols; j++)
+ {
+ double aval = (double)a[i][j];
+ float* pb = B;
- for (int k = 0; k < brows; k++)
- for (int l = 0; l < bcols; l++)
- result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
- }
-
+ for (int k = 0; k < brows; k++)
+ for (int l = 0; l < bcols; l++)
+ result[i * brows + k][j * bcols + l] = (int)(aval * (double)(*pb++));
+ }
+ }
+
return result;
}
@@ -81175,18 +82212,22 @@ public static int[][] Kronecker(this long[,] a, float[][] b, int[][] result)
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe int[] Kronecker(this long[] a, float[] b, int[] result)
+ public static int[] Kronecker(this long[] a, float[] b, int[] result)
{
- fixed (int* R = result)
- {
- int* pr = R;
- for (int i = 0; i < a.Length; i++)
- {
- double x = (double)a[i];
- for (int j = 0; j < b.Length; j++)
- *pr++ = (int)(x * (double)b[j]);
- }
- }
+ unsafe
+ {
+ fixed (int* R = result)
+ {
+ int* pr = R;
+ for (int i = 0; i < a.Length; i++)
+ {
+ double x = (double)a[i];
+ for (int j = 0; j < b.Length; j++)
+ *pr++ = (int)(x * (double)b[j]);
+ }
+ }
+ }
+
return result;
}
@@ -81380,7 +82421,7 @@ public static decimal[][] Dot(this decimal[][] a, decimal[,] b, decimal[][] resu
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe decimal[][] Dot(this decimal[,] a, decimal[][] b, decimal[][] result)
+ public static decimal[][] Dot(this decimal[,] a, decimal[][] b, decimal[][] result)
{
#if DEBUG
if (a.Columns() != b.Length || result.Length > a.Length || result.Columns() > b.Columns())
@@ -81394,21 +82435,24 @@ public static unsafe decimal[][] Dot(this decimal[,] a, decimal[][] b, decimal[]
var t = new decimal[K];
- fixed (decimal* A = a)
- for (int j = 0; j < M; j++)
- {
- for (int k = 0; k < t.Length; k++)
- t[k] = b[k][j];
+ unsafe
+ {
+ fixed (decimal* A = a)
+ for (int j = 0; j < M; j++)
+ {
+ for (int k = 0; k < t.Length; k++)
+ t[k] = b[k][j];
- decimal* pa = A;
- for (int i = 0; i < N; i++)
- {
- decimal s = (decimal)0;
- for (int k = 0; k < t.Length; k++)
- s += (decimal)((decimal)(*pa++) * (decimal)t[k]);
- result[i][j] = (decimal)s;
- }
- }
+ decimal* pa = A;
+ for (int i = 0; i < N; i++)
+ {
+ decimal s = (decimal)0;
+ for (int k = 0; k < t.Length; k++)
+ s += (decimal)((decimal)(*pa++) * (decimal)t[k]);
+ result[i][j] = (decimal)s;
+ }
+ }
+ }
#if DEBUG
if (!Matrix.IsEqual(C, result.ToMatrix().To(), 1e-4))
throw new Exception();
@@ -81486,7 +82530,7 @@ public static decimal[] Dot(this decimal[][] matrix, decimal[] columnVector, dec
#if NET45 || NET46 || NET462 || NETSTANDARD
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
- public static unsafe decimal[] Dot(this decimal[,] matrix, decimal[] columnVector, decimal[] result)
+ public static decimal[] Dot(this decimal[,] matrix, decimal[] columnVector, decimal[] result)
{
int cols = matrix.Columns();
int rows = matrix.Rows();
@@ -81495,55 +82539,54 @@ public static unsafe decimal[] Dot(this decimal[,] matrix, decimal[] columnVecto
if (cols != columnVector.Length || result.Length > rows)
throw new DimensionMismatchException();
#endif
+ unsafe
+ {
+ fixed (decimal* a = matrix)
+ fixed (decimal* x = columnVector)
+ fixed (decimal* r = result)
+ {
+ decimal* pa1 = a;
+ decimal* pa2 = a + cols;
+ decimal* pr = r;
- fixed (decimal* a = matrix)
- fixed (decimal* x = columnVector)
- fixed (decimal* r = result)
- {
- decimal* pa1 = a;
- decimal* pa2 = a + cols;
- decimal* pr = r;
-
- // Process rows two at a time
- for (int i = 0; i < rows / 2; i++)
- {
- decimal sum1 = 0, sum2 = 0;
- decimal* px = x;
-
- for (int j = 0; j < cols; j++)
- {
- sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*px));
- sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*px));
- px++;
- }
-
- *pr++ = (decimal)sum1;
- *pr++ = (decimal)sum2;
+ // Process rows two at a time
+ for (int i = 0; i < rows / 2; i++)
+ {
+ decimal sum1 = 0, sum2 = 0;
+ decimal* px = x;
+
+ for (int j = 0; j < cols; j++)
+ {
+ sum1 += (decimal)((decimal)(*pa1++) * (decimal)(*px));
+ sum2 += (decimal)((decimal)(*pa2++) * (decimal)(*px));
+ px++;
+ }
+
+ *pr++ = (decimal)sum1;
+ *pr++ = (decimal)sum2;
- // Now we skip a row
- pa1 = pa2;
- pa2 += cols;
- }
+ // Now we skip a row
+ pa1 = pa2;
+ pa2 += cols;
+ }
- // Process the remainder
- for (int i = 0; i < rows % 2; i++)
- {
- decimal sum = 0;
- decimal* px = x;
+ // Process the remainder
+ for (int i = 0; i < rows % 2; i++)
+ {
+ decimal sum = 0;
+ decimal* px = x;
- for (int j = 0; j < cols; j++)
- sum += (decimal)((decimal)(*pa1++) * (decimal)(*px++));
+ for (int j = 0; j < cols; j++)
+ sum += (decimal)((decimal)(*pa1++) * (decimal)(*px++));
- *pr = (decimal)sum;
- }
- }
+ *pr = (decimal)sum;
+ }
+ }
+ }
return result;
}
-
-
-
///
/// Computes the product