本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.PointwiseMultiply方法的典型用法代码示例。如果您正苦于以下问题:C# DenseMatrix.PointwiseMultiply方法的具体用法?C# DenseMatrix.PointwiseMultiply怎么用?C# DenseMatrix.PointwiseMultiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.PointwiseMultiply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: build_prob_map
public void build_prob_map()
{
Normal N_x = new Normal(X / 2, STD_X);
Normal N_y = new Normal(Y / 2, STD_Y);
DenseMatrix M_x = new DenseMatrix(Y, X, 0.0);
DenseMatrix M_y = new DenseMatrix(Y, X, 0.0);
DenseVector V_x = new DenseVector(X);
for (int i = 0; i < X; i++)
{
V_x[i] = N_x.Density(i);
}
for (int j = 0; j < Y; j++)
{
M_x.SetRow(j, V_x);
}
DenseVector V_y = new DenseVector(Y);
for (int i = 0; i < Y; i++)
{
V_y[i] = N_y.Density(i);
}
for (int j = 0; j < X; j++)
{
M_y.SetColumn(j, V_y);
}
DenseMatrix MULT = (DenseMatrix)M_x.PointwiseMultiply(M_y);
double s = MULT.Data.Sum();
MULT = (DenseMatrix)MULT.PointwiseDivide(new DenseMatrix(Y, X, s));
//this.dataGridView1.DataSource = MULT;
//Console.WriteLine(MULT.Data.Sum());
PROB_MAP_ORIG = MULT;
s = MULT[Y / 2, X / 2];
MULT = (DenseMatrix)MULT.PointwiseDivide(new DenseMatrix(Y, X, s));
/*
for (int i = 0; i < Y; i++)
{
Console.Write(i + " - ");
for (int j = 0; j < X; j++)
{
Console.Write(MULT[i, j] + " ");
}
Console.WriteLine();
Console.WriteLine();
}
*/
PROB_MAP = MULT;
}
示例2: disp_button_Click
private void disp_button_Click(object sender, EventArgs e)
{
/*
Normal N = new Normal(0.0, 1.0);
DenseVector VALS = new DenseVector(20, 0);
for (int i = -10; i < 10; i++)
{
VALS[i + 10] = N.Density(i);
Console.WriteLine(VALS[i + 10]);
}
*/
/*
//double[] d = new double[]{0,0};
DenseMatrix mu = new DenseMatrix(2, 1, new[] { 0.0, 0.0 });
DenseMatrix K = new DenseMatrix(1, 1, new[] { 1.0 });
DenseMatrix V = new DenseMatrix(2,2, new[] {4.0, 0.0, 0.0, 1.0 });
MatrixNormal mN = new MatrixNormal(mu, V, K);
Console.WriteLine(mu.RowCount);
Console.WriteLine(mu.ColumnCount);
Console.WriteLine(mN.Sample());
Console.WriteLine(mN.Sample());
DenseMatrix sample_pt = new DenseMatrix(2, 1, new[] { 0.0, 0.1 });
double pt = mN.Density(sample_pt);
*/
int M = 150;
int N = 200;
Normal N_x = new Normal(N/2, 50);
Normal N_y = new Normal(M/2, 30);
DenseMatrix M_x = new DenseMatrix(M, N, 0.0);
DenseMatrix M_y = new DenseMatrix(M, N, 0.0);
DenseVector V_x = new DenseVector(N);
for (int i = 0; i < N; i++)
{
V_x[i] = N_x.Density(i);
}
for (int j = 0; j < M; j++)
{
M_x.SetRow(j, V_x);
}
DenseVector V_y = new DenseVector(M);
for (int i = 0; i < M; i++)
{
V_y[i] = N_y.Density(i);
}
for (int j = 0; j < N; j++)
{
M_y.SetColumn(j, V_y);
}
DenseMatrix MULT = (DenseMatrix)M_x.PointwiseMultiply(M_y);
double s = MULT.Data.Sum();
MULT = (DenseMatrix)MULT.PointwiseDivide(new DenseMatrix(M,N,s));
//this.dataGridView1.DataSource = MULT;
//Console.WriteLine(MULT.Data.Sum());
s = MULT[M / 2, N / 2];
MULT = (DenseMatrix)MULT.PointwiseDivide(new DenseMatrix(M, N, s));
/*
for (int i = 0; i < M; i++)
{
Console.Write(i + " - ");
for (int j = 0; j < N; j++)
{
Console.Write(MULT[i, j] + " ");
}
Console.WriteLine();
Console.WriteLine();
}
*/
Console.WriteLine(Environment.ProcessorCount);
}
示例3: Run
//.........这里部分代码省略.........
// 2. Using LeftMultiply method and getting result into different vector instance
resultV = (DenseVector)matrixA.LeftMultiply(vector);
Console.WriteLine(@"Multiply vector by matrix using method LeftMultiply. (result = A.LeftMultiply(vec))");
Console.WriteLine(resultV.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// 3. Using LeftMultiply method and updating vector itself
matrixA.LeftMultiply(vector, vector);
Console.WriteLine(@"Multiply vector by matrix using method LeftMultiply. (A.LeftMultiply(vec, vec))");
Console.WriteLine(vector.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// Multiply matrix by matrix
// 1. Using operator "*"
resultM = matrixA * matrixB;
Console.WriteLine(@"Multiply matrix by matrix using operator *. (result = A * B)");
Console.WriteLine(resultM.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// 2. Using Multiply method and getting result into different matrix instance
resultM = (DenseMatrix)matrixA.Multiply(matrixB);
Console.WriteLine(@"Multiply matrix by matrix using method Multiply. (result = A.Multiply(B))");
Console.WriteLine(resultM.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// 3. Using Multiply method and updating matrix itself
matrixA.Multiply(matrixB, matrixA);
Console.WriteLine(@"Multiply matrix by matrix using method Multiply. (A.Multiply(B, A))");
Console.WriteLine(matrixA.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// Pointwise multiplies matrix with another matrix
// 1. Using PointwiseMultiply method and getting result into different matrix instance
resultM = (DenseMatrix)matrixA.PointwiseMultiply(matrixB);
Console.WriteLine(@"Pointwise multiplies matrix with another matrix using method PointwiseMultiply. (result = A.PointwiseMultiply(B))");
Console.WriteLine(resultM.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// 2. Using PointwiseMultiply method and updating matrix itself
matrixA.PointwiseMultiply(matrixB, matrixA);
Console.WriteLine(@"Pointwise multiplies matrix with another matrix using method PointwiseMultiply. (A.PointwiseMultiply(B, A))");
Console.WriteLine(matrixA.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// Pointwise divide matrix with another matrix
// 1. Using PointwiseDivide method and getting result into different matrix instance
resultM = (DenseMatrix)matrixA.PointwiseDivide(matrixB);
Console.WriteLine(@"Pointwise divide matrix with another matrix using method PointwiseDivide. (result = A.PointwiseDivide(B))");
Console.WriteLine(resultM.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// 2. Using PointwiseDivide method and updating matrix itself
matrixA.PointwiseDivide(matrixB, matrixA);
Console.WriteLine(@"Pointwise divide matrix with another matrix using method PointwiseDivide. (A.PointwiseDivide(B, A))");
Console.WriteLine(matrixA.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// Addition
// 1. Using operator "+"
resultM = matrixA + matrixB;
Console.WriteLine(@"Add matrices using operator +. (result = A + B)");
Console.WriteLine(resultM.ToString("#0.00\t", formatProvider));
Console.WriteLine();
// 2. Using Add method and getting result into different matrix instance
resultM = (DenseMatrix)matrixA.Add(matrixB);