/// <summary> /// /// </summary> /// <param name="method"></param> /// <returns></returns> public MatExpr Inv(MatrixDecomposition method = MatrixDecomposition.LU) { ThrowIfDisposed(); try { IntPtr retPtr = NativeMethods.core_MatExpr_inv(ptr, (int)method); MatExpr retVal = new MatExpr(retPtr); return(retVal); } catch (BadImageFormatException ex) { throw PInvokeHelper.CreateException(ex); } }
public void TestDecomposition() { System.Object[][] matrix = new System.Object[][] { new System.Object[] { 1, 2, 3 }, new System.Object[] { 4, 5, 6 }, new System.Object[] { 7, 8, 9 } }; List <System.Object> result = MatrixDecomposition.DecomposeMatrix(matrix); // matrix area should match spiral length Assert.That(result.Count, Is.EqualTo(matrix.Length * matrix[0].Length)); // matrix 0,0 should equal result 0 Assert.That(result[0], Is.EqualTo(matrix[0][0])); }
void Start() { System.Object[][] matrix = new System.Object[][] { new System.Object[] { 1, 2, 3 }, new System.Object[] { 4, 5, 6 }, new System.Object[] { 7, 8, 9 } }; List <System.Object> result = MatrixDecomposition.DecomposeMatrix(matrix); // log results result.ForEach(x => Debug.Log(x)); // create queue for animation QueuedResult = new Queue <int>(result.Select(x => (int)x)); StartCoroutine(renderNext()); }
/// <summary> /// solves linear system or a least-square problem /// </summary> /// <param name="src1"></param> /// <param name="src2"></param> /// <param name="dst"></param> /// <param name="flags"></param> /// <returns></returns> public static bool Solve(InputArray src1, InputArray src2, OutputArray dst, MatrixDecomposition flags = MatrixDecomposition.LU) { if (src1 == null) throw new ArgumentNullException("src1"); if (src2 == null) throw new ArgumentNullException("src2"); if (dst == null) throw new ArgumentNullException("dst"); src1.ThrowIfDisposed(); src2.ThrowIfDisposed(); dst.ThrowIfNotReady(); int ret = NativeMethods.core_solve(src1.CvPtr, src2.CvPtr, dst.CvPtr, (int)flags); dst.Fix(); return ret != 0; }
/// <summary> /// computes inverse or pseudo-inverse matrix /// </summary> /// <param name="src"></param> /// <param name="dst"></param> /// <param name="flags"></param> /// <returns></returns> public static double Invert(InputArray src, OutputArray dst, MatrixDecomposition flags = MatrixDecomposition.LU) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); double ret = NativeMethods.core_invert(src.CvPtr, dst.CvPtr, (int)flags); dst.Fix(); return ret; }
/// <summary> /// /// </summary> /// <param name="method"></param> /// <returns></returns> public MatExpr Inv(MatrixDecomposition method = MatrixDecomposition.LU) { ThrowIfDisposed(); try { IntPtr retPtr = NativeMethods.core_MatExpr_inv(ptr, (int)method); MatExpr retVal = new MatExpr(retPtr); return retVal; } catch (BadImageFormatException ex) { throw PInvokeHelper.CreateException(ex); } }
/// <summary> /// /// </summary> /// <param name="method"></param> /// <returns></returns> public Mat Inv(MatrixDecomposition method) { ThrowIfDisposed(); try { IntPtr retPtr = CppInvoke.core_Mat_inv(ptr, (int)method); Mat retVal = new Mat(retPtr); return retVal; } catch (BadImageFormatException ex) { throw PInvokeHelper.CreateException(ex); } }