public static YCbCr ConvertRgbtoYCbCr(RGB pixel) { DoubleVector rgbMatrix = new DoubleVector(pixel.GetAsArray()); DoubleVector yCbCrMatrix = DoubleVector.Add(NMathFunctions.Product(_conversionMatrix, rgbMatrix), _prefixMatrix); yCbCrMatrix = DoubleVector.Subtract(yCbCrMatrix, _offsetMatrix); return(new YCbCr((int)(yCbCrMatrix[0] + 0.5), (int)(yCbCrMatrix[1] + 0.5), (int)(yCbCrMatrix[2] + 0.5))); }
/// <summary> /// 奇异值分解 singular value decomposition /// </summary> public static void DoSvd() { Utility.Status("Creating SVD"); // 源文件数, 源文件中所有独特词数目, 源文件-索引, 源文件单词-索引 int totalNumberOfSourceFiles = TfDictionary.Count; int totalDistinctTermsInAllSourceFiles = IdfDictionary.Count; Dictionary <string, int> allSourceFilesWithIndex = TfDictionary.Keys.Select((x, index) => new { Name = x, Index = index }).ToDictionary(x => x.Name, x => x.Index); Dictionary <string, int> allSourceWordsWithIndex = IdfDictionary.Keys.Select((x, index) => new { Name = x, Index = index }).ToDictionary(x => x.Name, x => x.Index); // 源码矩阵 行数: 源码中单词数, 源文件数 double[,] sourceMatrix = new double[totalDistinctTermsInAllSourceFiles, totalNumberOfSourceFiles]; foreach (var fileNameWithTfDictionary in TfDictionary) { // 文件索引 int fileIndex = allSourceFilesWithIndex[fileNameWithTfDictionary.Key]; foreach (var fileWordWithTf in fileNameWithTfDictionary.Value) { sourceMatrix[allSourceWordsWithIndex[fileWordWithTf.Key], fileIndex] = fileWordWithTf.Value; } } // 创建矩阵 DoubleMatrix generalMatrix = new DoubleMatrix(sourceMatrix); // 奇异值分解 A = U S V.T var svd = new DoubleSVDecomp(generalMatrix); _uk = new Dictionary <int, DoubleMatrix>(); _sk = new Dictionary <int, DoubleMatrix>(); _vkTranspose = new Dictionary <int, DoubleMatrix>(); Utility.LsiKs.Where(x => x <= svd.Cols).ToList().ForEach(k => { // 创建k维矩阵 Utility.Status("Creating k matrix of size " + k); DoubleMatrix U = svd.LeftVectors; DoubleMatrix V = svd.RightVectors; // 通过数组创建矩阵, 行优先存储, 可再改 _uk.Add(k, Utility.GetDimMatrix(U, U.Rows, k)); _sk.Add(k, Utility.GetDiagonal(svd.SingularValues, k)); _vkTranspose.Add(k, NMathFunctions.Transpose(Utility.GetDimMatrix(V, V.Rows, k))); }); }
/// <summary> /// 计算 LSI 方法 /// </summary> /// <param name="outputFolderPath"></param> /// <param name="bugName"></param> /// <param name="queryText"></param> public static void ComputeLsi(string outputFolderPath, string bugName, List <string> queryText) { Utility.Status("Creating LSI: " + bugName); // 所有源码中的总独特词数 源文件 - 索引, 源文件单词 - 索引 int totalDistinctTermsInAllSourceFiles = IdfDictionary.Count; Dictionary <string, int> allSourceFilesWithIndex = TfDictionary.Keys.Select((x, index) => new { Name = x, Index = index }).ToDictionary(x => x.Name, x => x.Index); Dictionary <string, int> allSourceWordsWithIndex = IdfDictionary.Keys.Select((x, index) => new { Name = x, Index = index }).ToDictionary(x => x.Name, x => x.Index); // 为查询创建一个 1xm 的向量 double[,] queryMatrixTranspose = new double[1, totalDistinctTermsInAllSourceFiles]; queryText.ForEach(queryWord => { if (allSourceWordsWithIndex.ContainsKey(queryWord)) { queryMatrixTranspose[0, allSourceWordsWithIndex[queryWord]] = queryMatrixTranspose[0, allSourceWordsWithIndex[queryWord]] + 1; } }); // k列的 U 矩阵 var ks = _uk.Keys.Where(x => !File.Exists(outputFolderPath + LsiOutputFolderName + x + ".txt")).ToList(); // 为每个维度的矩阵计算相似度 foreach (var k in ks) { Utility.Status("Creating LSI for " + bugName + " where k=" + k); var uk = _uk[k]; var sk = _sk[k]; var vkTranspose = _vkTranspose[k]; DoubleMatrix q = new DoubleMatrix(queryMatrixTranspose); //qv = q * uk * sk.I [1xm,mxn,nxn = 1xn] DoubleMatrix qv = NMathFunctions.Product(q, uk); qv = NMathFunctions.Product(qv, NMathFunctions.Inverse(sk)); List <double> qDoubles = qv.Row(0).ToArray().ToList(); var similarityList = allSourceFilesWithIndex.Select(doc => new KeyValuePair <string, double>(doc.Key, Utility.GetSimilarity(qDoubles, vkTranspose.Col(doc.Value).ToArray().ToList()))); File.WriteAllLines(outputFolderPath + LsiOutputFolderName + k + ".txt", similarityList.OrderByDescending(x => x.Value).Select(x => x.Key + " " + x.Value.ToString("##.00000"))); } Utility.Status("Completed LSI: " + bugName); }
public static DoubleMatrix Advanced(DoubleMatrix x) { return(NMathFunctions.Product(NMathFunctions.Product(A, x), At)); }
private DoubleHermitianMatrix Create_SOIP_Matrix(Direction p, Direction dV, Direction sigma, double k, int nx, int ny) { DoubleHermitianMatrix result = new DoubleHermitianMatrix(2 * nx * ny); double theta; Band_Data dV_data; if (dV == Direction.x) { dV_data = dV_x; theta = theta_x; } else if (dV == Direction.y) { dV_data = dV_y; theta = theta_y; } else if (dV == Direction.z) { dV_data = new Band_Data(nx, ny, 0.0); theta = 0.0; } else { throw new Exception("Error - It's completely impossible to get here"); } if (p == Direction.x) { if (sigma == Direction.x) { throw new InvalidArgumentException("Error - no spin-orbit interaction between p_x and sigma_x"); } else if (sigma == Direction.y) { throw new NotImplementedException(); } else if (sigma == Direction.z) { for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { // off-diagonal couplings in x backward if (i != 0) { // for up -> up result[i * ny + j, i *ny + j - ny] = NMathFunctions.Exp(-1.0 * I * theta * dV_data.mat[i, j]) * tx; // for down -> down result[i * ny + j + nx * ny, i *ny + j - ny + nx * ny] = NMathFunctions.Exp(I * theta * dV_data.mat[i, j]) * tx; } // off-diagonal couplings in x forward if (i != nx - 1) { // for up -> up result[i * ny + j, i *ny + j + ny] = NMathFunctions.Exp(-1.0 * I * theta * dV_data.mat[i, j]) * tx; // for down -> down result[i * ny + j + nx * ny, i *ny + j + ny + nx * ny] = NMathFunctions.Exp(I * theta * dV_data.mat[i, j]) * tx; } // and diagonal couplings result[i * ny + j, i *ny + j] = -2.0 * Math.Cos(theta * dV_data.mat[i, j]) * tx; result[i * ny + j + nx * ny, i *ny + j + nx * ny] = -2.0 * Math.Cos(theta * dV_data.mat[i, j]) * tx; } } } else { throw new Exception("Error - It's completely impossible to get here"); } } else if (p == Direction.y) { if (sigma == Direction.x) { throw new NotImplementedException(); } else if (sigma == Direction.y) { throw new InvalidArgumentException("Error - no spin-orbit interaction between p_y and sigma_y"); } else if (sigma == Direction.z) { for (int i = 0; i < nx; i++) { for (int j = 0; j < ny; j++) { // off-diagonal couplings in y backward if (j != 0) { // for up -> up result[i * ny + j, i *ny + j - 1] = NMathFunctions.Exp(-1.0 * I * theta * dV_data.mat[i, j]) * ty; // for down -> down result[i * ny + j + nx * ny, i *ny + j - 1 + nx * ny] = NMathFunctions.Exp(I * theta * dV_data.mat[i, j]) * ty; } // off-diagonal couplings in y forward if (j != ny - 1) { // for up -> up result[i * ny + j, i *ny + j + 1] = NMathFunctions.Exp(-1.0 * I * theta * dV_data.mat[i, j]) * ty; // for down -> down result[i * ny + j + nx * ny, i *ny + j + 1 + nx * ny] = NMathFunctions.Exp(I * theta * dV_data.mat[i, j]) * ty; } // and diagonal couplings result[i * ny + j, i *ny + j] = -2.0 * Math.Cos(theta * dV_data.mat[i, j]) * ty; result[i * ny + j + nx * ny, i *ny + j + nx * ny] = -2.0 * Math.Cos(theta * dV_data.mat[i, j]) * ty; } } } else { throw new Exception("Error - It's completely impossible to get here"); } } else if (p == Direction.z) { throw new NotImplementedException("Error - at the moment, when momentum is in the direction of the wire, you should use a different method"); } else { throw new Exception("Error - It's completely impossible to get here"); } return(result); }
public double LibaryConditinalNumber() { return(NMathFunctions.ConditionNumber(NMathFunctions.TransposeProduct(Matrix, Matrix), NormType.OneNorm)); }
public DoubleVector Solve(DoubleVector v) { return(NMathFunctions.Solve(Matrix, v)); }
public double ComputeNormAgainst(DoubleVector b, DoubleVector xRes) { return(new DoubleVector(b - NMathFunctions.Product(Matrix, xRes)).TwoNorm()); }
DoubleComplexMatrix Product(DoubleComplexMatrix A, DoubleComplexMatrix B) { return(NMathFunctions.Product(A, B)); }
DoubleComplexMatrix Product(DoubleHermitianMatrix A, DoubleComplexMatrix B) { return(new DoubleComplexMatrix(NMathFunctions.Product(MatrixFunctions.ToGeneralMatrix(A), B))); }
private Coordinate Positioning_Proximity() { List <Gateway> gateways = IndoorPositioningClient.GetGateways(); /* get the Rssi values of the beacon in question from the server */ RssiValue[] rssiValues = IndoorPositioningClient.GetRssi(gateways.Count); CoordinateAndDistance[] cooDist = new CoordinateAndDistance[gateways.Count]; for (int i = 0; i < gateways.Count; i++) { cooDist[i] = new CoordinateAndDistance() { coordinate = new Coordinate() { Xaxis = (int)GetGatewayXaxis(gateways[i]), Yaxis = (int)GetGatewayYaxis(gateways[i]), }, dist = rssiValues[i].Rssi }; } Coordinate coordinateFirstAndSecondLine = new Coordinate(); Coordinate coordinateFirstAndThirdLine = new Coordinate(); Coordinate coordinateSecondAndThirdLine = new Coordinate(); /* Create a vector from the coordinates */ /* Measure the first point of crossing the first and second line*/ DoubleMatrix matrixFirstAndSecondLine = new DoubleMatrix(new double[, ] { { cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis }, { cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis } }); /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted. * We can have the exact point values with one of the reference points. */ if (NMathFunctions.Determinant(matrixFirstAndSecondLine) == 0) { return(cooDist[0].coordinate); } //matrixFirstAndSecondLine = matrixFirstAndSecondLine.Transform((p) => p * 2); DoubleMatrix inversedMatrixFirstAndSecondLine = NMathFunctions.Inverse(matrixFirstAndSecondLine); DoubleVector vectorFirstAndSecondLine = new DoubleVector(new double[] { cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(), cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow() }); vectorFirstAndSecondLine = vectorFirstAndSecondLine.Transform((p) => p / 2); DoubleVector coordinateVectorFirstAndSecondLine = NMathFunctions.Product(inversedMatrixFirstAndSecondLine, vectorFirstAndSecondLine); coordinateFirstAndSecondLine.Xaxis = (int)coordinateVectorFirstAndSecondLine[0]; coordinateFirstAndSecondLine.Yaxis = (int)coordinateVectorFirstAndSecondLine[1]; /* Measure the first point of crossing the first and third line*/ DoubleMatrix matrixFirstAndThirdLine = new DoubleMatrix(new double[, ] { { cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis }, { cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis } }); /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted. * We can have the exact point values with one of the reference points. */ if (NMathFunctions.Determinant(matrixFirstAndThirdLine) == 0) { return(cooDist[0].coordinate); } //matrixFirstAndThirdLine = matrixFirstAndThirdLine.Transform((p) => p * 2); DoubleMatrix inversedMatrixFirstAndThirdLine = NMathFunctions.Inverse(matrixFirstAndThirdLine); DoubleVector vectorFirstAndThirdLine = new DoubleVector(new double[] { cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(), cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow() }); vectorFirstAndThirdLine = vectorFirstAndThirdLine.Transform((p) => p / 2); DoubleVector coordinateVectorFirstAndThirdLine = NMathFunctions.Product(inversedMatrixFirstAndThirdLine, vectorFirstAndThirdLine); coordinateFirstAndThirdLine.Xaxis = (int)coordinateVectorFirstAndThirdLine[0]; coordinateFirstAndThirdLine.Yaxis = (int)coordinateVectorFirstAndThirdLine[1]; /* Measure the first point of crossing the first and third line*/ DoubleMatrix matrixSecondAndThirdLine = new DoubleMatrix(new double[, ] { { cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis }, { cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis } }); /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted. * We can have the exact point values with one of the reference points. */ if (NMathFunctions.Determinant(matrixSecondAndThirdLine) == 0) { return(cooDist[0].coordinate); } //matrixSecondAndThirdLine = matrixSecondAndThirdLine.Transform((p) => p * 2); DoubleMatrix inversedMatrixSecondAndThirdLine = NMathFunctions.Inverse(matrixSecondAndThirdLine); DoubleVector vectorSecondAndThirdLine = new DoubleVector(new double[] { cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow(), cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow() }); vectorSecondAndThirdLine = vectorSecondAndThirdLine.Transform((p) => p / 2); DoubleVector coordinateVectorSecondAndThirdLine = NMathFunctions.Product(inversedMatrixSecondAndThirdLine, vectorSecondAndThirdLine); coordinateSecondAndThirdLine.Xaxis = (int)coordinateVectorSecondAndThirdLine[0]; coordinateSecondAndThirdLine.Yaxis = (int)coordinateVectorSecondAndThirdLine[1]; int xaxis = (coordinateFirstAndSecondLine.Xaxis + coordinateFirstAndThirdLine.Xaxis + coordinateSecondAndThirdLine.Xaxis) / 3; int yaxis = (coordinateFirstAndSecondLine.Yaxis + coordinateFirstAndThirdLine.Yaxis + coordinateSecondAndThirdLine.Yaxis) / 3; Debug.WriteLine("Xaxis:" + xaxis); Debug.WriteLine("Yaxis:" + yaxis); return(new Coordinate() { Xaxis = xaxis, Yaxis = yaxis }); }
private Coordinate Positioning_KnnProximity(List <AdjustedFingerprinting> fingerprintings) { int k = 3; /* run the knn classifier on the data */ KnnClassifier classifier = new KnnClassifier(); /* After fetching and processing the fingerprinting data, I am able to get the class count. * Basically, each of the reference point is a class to be classified to. */ int numClasses = IndoorPositioningClient.GetPoints(environment.EnvironmentId).Count; int gatewayCount = fingerprintings[0].RssiValueAndGateway.Count; /* get the Rssi values of the beacon in question from the server */ RssiValue[] rssiValues = IndoorPositioningClient.GetRssi(gatewayCount); /* we will use also gateway count on the area as K constant */ CoordinateAndDistance[] cooDist = classifier.GetNearestNeighbors(rssiValues, fingerprintings, numClasses, k); Coordinate coordinateFirstAndSecondLine = new Coordinate(); Coordinate coordinateFirstAndThirdLine = new Coordinate(); Coordinate coordinateSecondAndThirdLine = new Coordinate(); /* Create a vector from the coordinates */ /* Measure the first point of crossing the first and second line*/ DoubleMatrix matrixFirstAndSecondLine = new DoubleMatrix(new double[, ] { { cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis }, { cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis } }); /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted. * We can have the exact point values with one of the reference points. */ if (NMathFunctions.Determinant(matrixFirstAndSecondLine) == 0) { return(classifier.Vote(cooDist, fingerprintings, numClasses, k)); } //matrixFirstAndSecondLine = matrixFirstAndSecondLine.Transform((p) => p * 2); DoubleMatrix inversedMatrixFirstAndSecondLine = NMathFunctions.Inverse(matrixFirstAndSecondLine); DoubleVector vectorFirstAndSecondLine = new DoubleVector(new double[] { cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(), cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow() }); vectorFirstAndSecondLine = vectorFirstAndSecondLine.Transform((p) => p / 2); DoubleVector coordinateVectorFirstAndSecondLine = NMathFunctions.Product(inversedMatrixFirstAndSecondLine, vectorFirstAndSecondLine); coordinateFirstAndSecondLine.Xaxis = (int)coordinateVectorFirstAndSecondLine[0]; coordinateFirstAndSecondLine.Yaxis = (int)coordinateVectorFirstAndSecondLine[1]; /* Measure the first point of crossing the first and third line*/ DoubleMatrix matrixFirstAndThirdLine = new DoubleMatrix(new double[, ] { { cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis }, { cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis } }); /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted. * We can have the exact point values with one of the reference points. */ if (NMathFunctions.Determinant(matrixFirstAndThirdLine) == 0) { return(classifier.Vote(cooDist, fingerprintings, numClasses, k)); } //matrixFirstAndThirdLine = matrixFirstAndThirdLine.Transform((p) => p * 2); DoubleMatrix inversedMatrixFirstAndThirdLine = NMathFunctions.Inverse(matrixFirstAndThirdLine); DoubleVector vectorFirstAndThirdLine = new DoubleVector(new double[] { cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(), cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow() }); vectorFirstAndThirdLine = vectorFirstAndThirdLine.Transform((p) => p / 2); DoubleVector coordinateVectorFirstAndThirdLine = NMathFunctions.Product(inversedMatrixFirstAndThirdLine, vectorFirstAndThirdLine); coordinateFirstAndThirdLine.Xaxis = (int)coordinateVectorFirstAndThirdLine[0]; coordinateFirstAndThirdLine.Yaxis = (int)coordinateVectorFirstAndThirdLine[1]; /* Measure the first point of crossing the first and third line*/ DoubleMatrix matrixSecondAndThirdLine = new DoubleMatrix(new double[, ] { { cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis }, { cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis } }); /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted. * We can have the exact point values with one of the reference points. */ if (NMathFunctions.Determinant(matrixSecondAndThirdLine) == 0) { return(classifier.Vote(cooDist, fingerprintings, numClasses, k)); } //matrixSecondAndThirdLine = matrixSecondAndThirdLine.Transform((p) => p * 2); DoubleMatrix inversedMatrixSecondAndThirdLine = NMathFunctions.Inverse(matrixSecondAndThirdLine); DoubleVector vectorSecondAndThirdLine = new DoubleVector(new double[] { cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow(), cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow() }); vectorSecondAndThirdLine = vectorSecondAndThirdLine.Transform((p) => p / 2); DoubleVector coordinateVectorSecondAndThirdLine = NMathFunctions.Product(inversedMatrixSecondAndThirdLine, vectorSecondAndThirdLine); coordinateSecondAndThirdLine.Xaxis = (int)coordinateVectorSecondAndThirdLine[0]; coordinateSecondAndThirdLine.Yaxis = (int)coordinateVectorSecondAndThirdLine[1]; //DoubleMatrix matrixFirstAndThirdLine = new DoubleMatrix(new double[,] //{ // { // cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis, // cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis // }, // { // cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, // cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis // }, // { // cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, // cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis // } //}); //DoubleMatrix inversedMatrix = NMathFunctions.Inverse(matrix); //DoubleVector vector = new DoubleVector(new double[] //{ // cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(), // cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow(), // cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow() //}); //DoubleVector coordinateVector = NMathFunctions.Product(inversedMatrix, vector); //coordinate.Xaxis = (int)coordinateVector[0]; //coordinate.Xaxis = (int)coordinateVector[1]; //Matrix linesMatrix = new Matrix( // cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis, // cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis, // cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, // cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis, // cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis, // cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis); ////Vector distances = new Vector( //// coordinateAndDistances[0].coordinate.Xaxis - coordinateAndDistances[1].coordinate.Xaxis,); int xaxis = (coordinateFirstAndSecondLine.Xaxis + coordinateFirstAndThirdLine.Xaxis + coordinateSecondAndThirdLine.Xaxis) / 3; int yaxis = (coordinateFirstAndSecondLine.Yaxis + coordinateFirstAndThirdLine.Yaxis + coordinateSecondAndThirdLine.Yaxis) / 3; Debug.WriteLine("Xaxis:" + xaxis); Debug.WriteLine("Yaxis:" + yaxis); return(new Coordinate() { Xaxis = xaxis, Yaxis = yaxis }); }