本文整理汇总了C#中Matrix.Transpose方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Transpose方法的具体用法?C# Matrix.Transpose怎么用?C# Matrix.Transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix.Transpose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: compress
public Matrix compress(int k)
{
//Setting up compression matrix
int rows = matrix.RowCount;
int cols = matrix.ColumnCount;
Matrix VK = new Matrix(cols, k);
Matrix UK = new Matrix(rows, k);
double SK;
Matrix Ak = new Matrix(rows, cols);
//Begin compressing matrix according to algorithm
Console.WriteLine("Compressing matrix... K = " + k);
for (int i = 0; i < k; i++)
{
//Making V, U, and S for compressed matrix
VK = v.GetColumnVector(i).ToColumnMatrix();
UK = u.GetColumnVector(i).ToColumnMatrix();
SK = d[i, i];
//Performing operations on V, U, S
VK.Transpose();
UK = UK.Multiply(VK);
UK.Multiply(SK);
Ak.Add(UK);
}
//Returning data
SV1 = d[0, 0];
SVK1 = d[k + 1, k + 1];
Console.WriteLine("SV1: " + d[0, 0] + " SVK1: " + d[k + 1, k + 1]);
return Ak;
}
示例2: SVD
public SVD(Matrix A)
{
int m = A.RowCount;
int n = A.ColumnCount;
int p = Math.Min( m, n );
U = new Matrix(m,p);
V = new Matrix(n,p);
S = new Matrix(p);
Matrix B;
if( m >= n )
{
B = A;
Decomposition( B, U, S, V );
}
else
{
B = A.Transpose();
Decomposition( B, V, S, U );
}
if (B != A)
{
B.Dispose();
}
}
示例3: Simple
public void Simple()
{
var matrix1 = new Matrix(2, 3);
matrix1[0, 0] = 1;
matrix1[0, 1] = 4;
matrix1[0, 2] = 5;
matrix1[1, 0] = -3;
matrix1[1, 1] = 2;
matrix1[1, 2] = 7;
// T [ 1, -3]
// [ 1, 4, 5] = [ 4, 2]
// [-3, 2, 7] [ 5, 7]
var expectedMatrix = new Matrix(3, 2);
expectedMatrix[0, 0] = 1;
expectedMatrix[0, 1] = -3;
expectedMatrix[1, 0] = 4;
expectedMatrix[1, 1] = 2;
expectedMatrix[2, 0] = 5;
expectedMatrix[2, 1] = 7;
var result = matrix1.Transpose();
Assert.IsTrue(result.Equals(expectedMatrix));
}
示例4: Draw
public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Matrix mat, bool triangleStrip)
{
if (VertexBuffer == null)
{
VertexBuffer = new Buffer(renderContext.Device, Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, Marshal.SizeOf(points[0]));
VertexBufferBinding = new VertexBufferBinding(VertexBuffer, Marshal.SizeOf((points[0])), 0);
}
renderContext.devContext.InputAssembler.PrimitiveTopology = triangleStrip ? PrimitiveTopology.TriangleStrip : PrimitiveTopology.TriangleList;
renderContext.BlendMode = BlendMode.Alpha;
renderContext.setRasterizerState(TriangleCullMode.Off);
mat.Transpose();
WarpOutputShader.MatWVP = mat;
WarpOutputShader.Use(renderContext.devContext, false);
renderContext.SetVertexBuffer(VertexBufferBinding);
var box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None);
Utilities.Write(box.DataPointer, points, 0, count);
renderContext.devContext.UnmapSubresource(VertexBuffer, 0);
renderContext.devContext.PixelShader.SetShaderResource(0, null);
renderContext.devContext.Draw(count, 0);
}
示例5: PolynomialRegression
public Vector PolynomialRegression(List<Point> points, int order)
{
Matrix paramM = new Matrix(order + 1, points.Count);
Vector yV = new Vector(points.Count);
int j = 0;
foreach (var c in points)
{
yV[j] = c.Y;
for (int i = 0; i <= order; i++)
paramM[i, j] = Math.Pow(c.X, i);
j++;
}
Matrix step1 = (paramM.Transpose() * paramM).Inverse();
Vector bV = (paramM.Transpose() * paramM).Inverse() * (paramM.Transpose() * yV);
return bV;
}
示例6: BuildModel
public ILinearRegressionModel BuildModel(Matrix<double> matrixX, Vector<double> vectorY, ILinearRegressionParams linearRegressionParams)
{
var normalizationMatrix = Matrix<double>.Build.DenseIdentity(matrixX.ColumnCount, matrixX.ColumnCount) * regularizationConst;
var xT = matrixX.Transpose();
var xTx = xT.Multiply(matrixX) + normalizationMatrix;
var inversedXTX = xTx.Inverse();
var xTy = xT.Multiply(vectorY);
return new LinearRegressionModel(inversedXTX.Multiply(xTy));
}
示例7: UnApplyTransform
public CloudPoint UnApplyTransform(Matrix R, Vector T)
{
// R is trivially invertible because it is a rotation matrix
var Rt = new Matrix(R);
Rt.Transpose(); // yo this language is pass by ref so be careful
var newLocation = (R * (location - T).ToColumnMatrix()).GetColumnVector(0);
return new CloudPoint(newLocation, this.color, this.normal);
}
示例8: Main
static void Main(string[] args)
{
//Creates Default_Matrix with given dimensions the matrix is empty
Matrix Default_Matrix = new Matrix(2, 2);
Console.WriteLine("Original Matrix:");
Console.WriteLine();
Default_Matrix.print();
Console.WriteLine();
double min; double max;
Point min_loc = new Point();
Point max_loc = new Point();
//Matrix to multiply,add,subtract, or test equals by.
double[,] Test_Matrix = { { 1, 2 }, { 1, 2 }};
Console.WriteLine("This is the Matrix after being multiplied by Test_Matrix:");
Console.WriteLine();
Default_Matrix.Mul(Test_Matrix);
Console.WriteLine();
Console.WriteLine("This is the Matrix after being multiplied by a scalar:");
Console.WriteLine();
Default_Matrix.scale(4);
Console.WriteLine();
Console.WriteLine("This is the Matrix that resulted from multiplying by the scalar and added to it is Test_Matrix:");
Console.WriteLine();
Default_Matrix.Add(Test_Matrix);
Console.WriteLine();
Console.WriteLine("This is the Matrix that resulted from multiplying by the scalar and then subtracting from it Test_Matrix:");
Console.WriteLine();
Default_Matrix.Sub(Test_Matrix);
Console.WriteLine();
Console.WriteLine("This is the Matrix transposed:");
Console.WriteLine();
Default_Matrix.Transpose();
Console.WriteLine();
Console.WriteLine("True or False: the matrices are equal?");
Console.WriteLine();
Default_Matrix.Equals(Test_Matrix);
Console.WriteLine();
Console.WriteLine("The current Matrix is reset to identity matrix:");
Console.WriteLine();
Default_Matrix.SetIdentity();
Console.WriteLine();
Default_Matrix.MinMax(out min, out max, out min_loc, out max_loc);
Console.WriteLine();
double j = Default_Matrix.Data;
Console.Write(j);
Default_Matrix.Data = 4;
Default_Matrix.print();
Console.Read();
}
示例9: Main
static void Main(string[] args)
{
double[] startMatrix = new double[] { 5.0, 6.0, 7.0, 9.0, 10.0, 1.0, 1.0, 2.0, 1.0, 1.0 };
Matrix myMatrix = new Matrix(startMatrix, 5);
Matrix mySecondMatrix = new Matrix(startMatrix.Reverse().ToArray(), 2);
myMatrix.ShowMatrix();
mySecondMatrix.ShowMatrix();
var prodMatrix = myMatrix * mySecondMatrix;
prodMatrix.ShowMatrix();
myMatrix.Transpose().ShowMatrix();
prodMatrix.ShowMatrix();
Console.ReadKey();
}
示例10: createStationaryDistributionOf
public Vector<double> createStationaryDistributionOf(Matrix<double> randomWalkMX)
{
Evd<double> evdOfRandomWalkMXTransposed = randomWalkMX.Transpose().Evd();
Vector<double> pi = null;
for (int idx = 0; idx < evdOfRandomWalkMXTransposed.EigenValues.Count; idx++)
{
if (Math.Abs(evdOfRandomWalkMXTransposed.EigenValues[idx].Real - 1.0) < 0.00001)
{
pi = evdOfRandomWalkMXTransposed.EigenVectors.Column(idx);
}
}
// see: https://en.wikipedia.org/wiki/Markov_chain#Stationary_distribution_relation_to_eigenvectors_and_simplices
double sumPi = pi.Sum();
pi = pi.Multiply(1 / sumPi);
return pi;
}
示例11: Vector
public Vector(Matrix mat)
{
if (mat.Rows != 1 && mat.Columns != 1)
{
throw new MatrixException("Cannot convert matrix to Vector. It has more than one row or column");
}
if (mat.Columns == 1)
{
mat = mat.Transpose();
}
if (mat.Rows == 1)
{
Size = mat.Columns;
for (var i = 0; i < mat.Columns; i++)
{
this[i] = mat[0, i];
}
}
}
示例12: Main
static void Main()
{
try
{
Console.WriteLine("Some hard coded tests:");
int[,] matrix1 = new int[,]
{
{1, 2, -3},
{2, 1, 3},
{3, 1, 2}
};
int[,] matrix2 = new int[,]
{
{4, 5, 6},
{-1, 0, 7},
{3, 2, 1}
};
Matrix<int> m1 = new Matrix<int>(matrix1);
Matrix<int> m2 = new Matrix<int>(matrix2);
Console.WriteLine(m1 + m2);
Console.WriteLine(m1 - m2);
Console.WriteLine(m1 * m2);
Console.WriteLine(m1.Transpose());
Console.WriteLine(m1 * 5);
if (m1)
{
Console.WriteLine("m1 contains non-zero items.");
}
Matrix<decimal> matrixOfDecimals = new Matrix<decimal>(10, 10);
Console.WriteLine(matrixOfDecimals);
}
catch (MatrixException ex)
{
Console.WriteLine(ex.Message);
}
}
示例13: Start
// Use this for initialization
void Start()
{
// Save a pointer to the fusion engine
fusionEngine = GetComponentInParent<FusionEngine>();
// Get a pointer to the target
targets = GameObject.FindGameObjectsWithTag("Target");
// Noise distribution
nd = new NormalDistribution(0, 1);
noiseCovariance = new Matrix(3, 3);
noiseCovariance[0, 0] = 1e-3;
noiseCovariance[1, 1] = 1e-3;
noiseCovariance[2, 2] = 1e-3;
noiseCovCholT = noiseCovariance.CholeskyDecomposition.TriangularFactor.Clone();
noiseCovCholT.Transpose();
// Reset time since the last update
timeSinceLastUpdateSec = 0.0f;
}
示例14: PlanarProjection
public PlanarProjection(double originLat, double originLon)
{
LLACoord originLLA = new LLACoord(originLat, originLon, 0);
originECEF = WGS84.LLAtoECEF(originLLA);
double slon = Math.Sin(originLon);
double clon = Math.Cos(originLon);
double slat = Math.Sin(originLat);
double clat = Math.Cos(originLat);
R_enu_to_ecef = new Matrix(3, 3);
R_enu_to_ecef[0, 0] = -slon;
R_enu_to_ecef[0, 1] = -clon * slat;
R_enu_to_ecef[0, 2] = clon * clat;
R_enu_to_ecef[1, 0] = clon;
R_enu_to_ecef[1, 1] = -slon * slat;
R_enu_to_ecef[1, 2] = slon * clat;
R_enu_to_ecef[2, 0] = 0;
R_enu_to_ecef[2, 1] = clat;
R_enu_to_ecef[2, 2] = slat;
R_ecef_to_enu = R_enu_to_ecef.Transpose();
}
示例15: calculate_covariance_matrix_from_samples
public double[,] calculate_covariance_matrix_from_samples()
{
covariance_matrix = new double[num_of_features, num_of_features];
for (int i = 0; i < num_of_features; i++)
{
for (int j = 0; j < num_of_features; j++)
{
covariance_matrix[i, j] = 0;
for (int k = 0; k < num_of_training_samples; k++)
{
covariance_matrix[i, j] += (training_samples[k].features_values[i,0] - meus_vector[i,0]) * (training_samples[k].features_values[j,0] - meus_vector[j,0]);
}
covariance_matrix[i, j] = covariance_matrix[i, j] / num_of_training_samples;
}
}
/**
* Use MathDotNET Numerics
**/
Matrix_Sigma = Matrix<double>.Build.DenseOfArray(covariance_matrix);
Matrix_Sigma_Transpose = Matrix_Sigma.Transpose();
Matrix_Sigma_Inverse = Matrix_Sigma.Inverse();
return covariance_matrix;
}