本文整理汇总了C#中DotNetMatrix.GeneralMatrix.Solve方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralMatrix.Solve方法的具体用法?C# GeneralMatrix.Solve怎么用?C# GeneralMatrix.Solve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetMatrix.GeneralMatrix
的用法示例。
在下文中一共展示了GeneralMatrix.Solve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreCalc
// In bilinear mode, the warping functions are:
// x' = a0 + a1 x y + a2 x + a3 y
// y' = b0 + b1 x y + b2 x + b3 y
//
// Here, we have two sets of four equations. In the first set, the a# factors
// are the unknowns, in the second set the b# factors.
// The equations are of the form:
// a0 + xy a1 + x a2 + y a3 = x'
// The left hand side is identical for both sets. The right hand side differs.
// Therefore, we can solve them in one operation.
// The left hand side factors are put in the 4x4 matrix mxLeft, the right side
// factors are put in the 4x2 matrix mxRight.
// After solving, the first column of m_mxWarpFactors contains a0, a1, a2, a3; the
// second columne contains b0, b1, b2, b3.
private void PreCalc(PointD[] destPoints, PointD[] srcPoints)
{
var mxLeft = new GeneralMatrix(4, 4);
var mxRight = new GeneralMatrix(4, 2);
for (int row = 0; row < 4; row++)
{
mxLeft.Array[row][0] = 1.0;
mxLeft.Array[row][1] = srcPoints[row].X * srcPoints[row].Y;
mxLeft.Array[row][2] = srcPoints[row].X;
mxLeft.Array[row][3] = srcPoints[row].Y;
mxRight.Array[row][0] = destPoints[row].X;
mxRight.Array[row][1] = destPoints[row].Y;
}
_mxWarpFactors = mxLeft.Solve(mxRight);
}
示例2: Main
//.........这里部分代码省略.........
errorCount = try_failure(errorCount, "Condition()...", "incorrect condition number calculation");
System.Console.Out.WriteLine(e.Message);
}
int n = A.ColumnDimension;
A = A.GetMatrix(0, n - 1, 0, n - 1);
A.SetElement(0, 0, 0.0);
LUDecomposition LU = A.LUD();
try
{
check(A.GetMatrix(LU.Pivot, 0, n - 1), LU.L.Multiply(LU.U));
try_success("LUDecomposition...", "");
}
catch (System.SystemException e)
{
errorCount = try_failure(errorCount, "LUDecomposition...", "incorrect LU decomposition calculation");
System.Console.Out.WriteLine(e.Message);
}
X = A.Inverse();
try
{
check(A.Multiply(X), GeneralMatrix.Identity(3, 3));
try_success("Inverse()...", "");
}
catch (System.SystemException e)
{
errorCount = try_failure(errorCount, "Inverse()...", "incorrect Inverse calculation");
System.Console.Out.WriteLine(e.Message);
}
O = new GeneralMatrix(SUB.RowDimension, 1, 1.0);
SOL = new GeneralMatrix(sqSolution);
SQ = SUB.GetMatrix(0, SUB.RowDimension - 1, 0, SUB.RowDimension - 1);
try
{
check(SQ.Solve(SOL), O);
try_success("Solve()...", "");
}
catch (System.ArgumentException e1)
{
errorCount = try_failure(errorCount, "Solve()...", e1.Message);
System.Console.Out.WriteLine(e1.Message);
}
catch (System.SystemException e)
{
errorCount = try_failure(errorCount, "Solve()...", e.Message);
System.Console.Out.WriteLine(e.Message);
}
A = new GeneralMatrix(pvals);
CholeskyDecomposition Chol = A.chol();
GeneralMatrix L = Chol.GetL();
try
{
check(A, L.Multiply(L.Transpose()));
try_success("CholeskyDecomposition...", "");
}
catch (System.SystemException e)
{
errorCount = try_failure(errorCount, "CholeskyDecomposition...", "incorrect Cholesky decomposition calculation");
System.Console.Out.WriteLine(e.Message);
}
X = Chol.Solve(GeneralMatrix.Identity(3, 3));
try
{
check(A.Multiply(X), GeneralMatrix.Identity(3, 3));
try_success("CholeskyDecomposition Solve()...", "");
}
catch (System.SystemException e)
示例3: TestSolve
public void TestSolve()
{
GeneralMatrix _ls = new GeneralMatrix(2,2);
_ls.SetElement(0,0,1);
_ls.SetElement(0,1,2);
_ls.SetElement(1,0,3);
_ls.SetElement(1,1,4);
GeneralMatrix _rs = new GeneralMatrix(2,1);
_rs.SetElement(0,0,-3);
_rs.SetElement(1,0,-5);
GeneralMatrix _solution = _ls.Solve(_rs);
Assert.AreEqual(_solution.GetElement(0,0),1);
Assert.AreEqual(_solution.GetElement(1,0),-2);
}
示例4: PreCalc
// In perspective mode, the warping functions are:
// x' = (a0 + a1 x + a2 y) / (c0 x + c1 y + 1)
// y' = (b0 + b1 x + b2 y) / (c0 x + c1 y + 1)
//
// The following calculates the factors a#, b# and c#.
// We do this by creating a set of eight equations with a#, b# and c# as unknowns.
// The equations are derived by:
// 1. substituting the srcPoints for (x, y);
// 2. substituting the corresponding destPoints for (x', y');
// 3. solving the resulting set of equations, with the factors as unknowns.
//
// The equations are like these:
// a0 x a1 y a2 0 0 0 -xx'c0 -yx'c1 = x'
// 0 0 0 b0 x b1 y b2 -xy'c0 -yy'c1 = y'
// The known factors of left hand side ar put in the 8x8 matrix mxLeft for
// all four point pairs, and the right hand side in the one column matrix mxRight.
// After solving, m_mxWarpFactors contains a0, a1, a2, b0, b1, b2, c0, c1.
private void PreCalc(PointD[] destPoints, PointD[] srcPoints)
{
var mxLeft = new GeneralMatrix(8, 8); //mxLeft.Null();
var mxRight = new GeneralMatrix(8, 1);
var row = 0;
for (int i = 0; i < 4; i++)
{
mxLeft.Array[row][0] = 1.0;
mxLeft.Array[row][1] = srcPoints[i].X;
mxLeft.Array[row][2] = srcPoints[i].Y;
mxLeft.Array[row][6] = - srcPoints[i].X * destPoints[i].X;
mxLeft.Array[row][7] = - srcPoints[i].Y * destPoints[i].X;
mxRight.Array[row][0] = destPoints[i].X;
row++;
mxLeft.Array[row][3] = 1.0f;
mxLeft.Array[row][4] = srcPoints[i].X;
mxLeft.Array[row][5] = srcPoints[i].Y;
mxLeft.Array[row][6] = - srcPoints[i].X * destPoints[i].Y;
mxLeft.Array[row][7] = - srcPoints[i].Y * destPoints[i].Y;
mxRight.Array[row][0] = destPoints[i].Y;
row++;
}
_mxWarpFactors = mxLeft.Solve(mxRight);
}
示例5: FillInFendu
//.........这里部分代码省略.........
if (askdlg.ShowDialog() != DialogResult.OK)
return;
if (!Decimal.TryParse(askdlg.result, out t_start) || (t_start < ptn1))
{
MessageBox.Show("无效的起始温度,分度表不能外插");
return;
}
askdlg.Message = "请输入分度表结束温度";
if (askdlg.ShowDialog() != DialogResult.OK)
return;
if (!Decimal.TryParse(askdlg.result, out t_end) || (t_end > ptp2))
{
MessageBox.Show("无效的结束温度,分度表不能外插");
return;
}
Decimal s = t_start;
Decimal e = t_end;
if ((s < 0) && (nn < 3))
{
MessageBox.Show("检定点不足。-200℃ ~ 0 ℃的分度表计算至少有需要3个检定点.");
return;
}
if ((e > 0) && (np < 2))
{
MessageBox.Show("检定点不足。0℃ ~ 850 ℃的分度表计算至少有需要2个检定点.");
return;
}
double[] xn = new double[3]; //A,B,C
double[] xp = new double[2]; //A,B
GeneralMatrix gxn;
GeneralMatrix gxp;
if (nn >= 3)
{
GeneralMatrix gm = new GeneralMatrix(mn);
gxn = gm.Solve(new GeneralMatrix(yn, yn.Length));
xn[0] = gxn.GetElement(0, 0);
xn[1] = gxn.GetElement(1, 0);
xn[2] = gxn.GetElement(2, 0);
}
if (np >= 2)
{
GeneralMatrix gm = new GeneralMatrix(mp);
gxp = gm.Solve(new GeneralMatrix(yp, yp.Length));
xp[0] = gxp.GetElement(0, 0);
xp[1] = gxp.GetElement(1, 0);
}
List<string> rows = new List<string>();
while (s <= e)
{
double sv = Convert.ToDouble(s);
if (s < 0)
{
rows.Add(String.Format("{0}\t{1:F4}", s.ToString(), r0 * (1 + xn[0] * sv + xn[1] * sv * sv + xn[2] * (sv - 100) * sv * sv * sv)));
}
else
{
rows.Add(String.Format("{0}\t{1:F4}", s.ToString(), r0 * (1 + xp[0] * sv + xp[1] * sv * sv)));
}
s = s + 1;
}
saveFileDialog1.DefaultExt = ".doc";
saveFileDialog1.Filter = "DOC File(*.doc)|*.doc|All Files(*.*)|*.*";
saveFileDialog1.FileName = DateTime.Now.ToString("yyyy-MM-dd") + "分度表证书.doc";
if (saveFileDialog1.ShowDialog() != DialogResult.OK)
return;
string tofile = saveFileDialog1.FileName;
try
{
string tmpl = "分度表";
string src = Path.Combine(Util.basedir, "报告模板\\" + tmpl + ".doc");
File.Copy(src, tofile, true);
doctool.PrepareWord(tofile);
docopen = true;
doctool.FillInTableByBookMarks("ITEMS", rows);
doctool.FillInHeader(tofile, data_record.Properties(), ibcid, Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader);
doctool.FillInHeader(tofile, data_record.Properties(), ibcid, Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader);
doctool.SaveWord(tofile);
MessageBox.Show("导出" + tmpl + "成功");
docopen = false;
return;
}
catch (Exception ex)
{
MessageBox.Show("导出报告失败: " + ex.Message);
if (docopen)
doctool.SaveWord(tofile);
docopen = false;
}
}