/// <summary> /// Assert the compatibility of the underlying AlignedArray for the input matrix in terms of alignment amount. /// </summary> /// <param name="values">The input matrix</param> public static void AssertCompatible(ICpuFullMatrix values) { #if DEBUG var mat = values as TMatrix; Contracts.AssertValue(mat); Contracts.Assert(mat.Items.CbAlign == SseUtils.CbAlign); #endif }
/// <summary> /// Assert the compatibility of the underlying AlignedArray for the input matrix in terms of alignment amount. /// </summary> /// <param name="values">The input matrix</param> public static void AssertCompatible(ICpuFullMatrix values) { #if DEBUG var mat = values as TMatrix; Contracts.AssertValue(mat); Contracts.Assert((mat.Items.CbAlign % CpuMathUtils.GetVectorAlignment()) == 0); #endif }
/// <summary> /// Matrix multiplication: /// if (add) /// dst = mat * src /// else /// dest += mat * src /// </summary> /// <param name="add">The addition flag</param> /// <param name="mat">The multiplier matrix</param> /// <param name="src">The source vector</param> /// <param name="dst">The destination vector</param> public static void MatTimesSrc(bool add, ICpuFullMatrix mat, ICpuVector src, ICpuVector dst) { bool colMajor = typeof(TMatrix) == typeof(CpuAlignedMatrixCol); AssertCompatible(mat, src, dst); var m = A(mat); SseUtils.MatTimesSrc(colMajor, add, m.Items, A(src).Items, A(dst).Items, m.RunCnt); }
/// <summary> /// Matrix transpose multiplication: /// dst = mat' * src /// </summary> /// <param name="mat">The multiplier matrix</param> /// <param name="src">The source vector</param> /// <param name="dst">The destination vector</param> public static void MatTranTimesSrc(ICpuFullMatrix mat, ICpuVector src, ICpuVector dst) { bool colMajor = typeof(TMatrix) == typeof(CpuAlignedMatrixCol); AssertCompatible(mat, dst, src); var m = A(mat); CpuMathUtils.MatrixTimesSource(!colMajor, m.Items, A(src).Items, A(dst).Items, m.RunCnt); }
/// <summary> /// Asserts the following: /// 1. The compatibility of the underlying AlignedArray for mat in terms of alignment amount. /// 2. The compatibility of the underlying AlignedArray for src in terms of alignment amount. /// 3. The compatibility of the underlying AlignedArray for dst in terms of alignment amount. /// 4. The compatibility of the matrix-vector multiplication mat * src = dst. /// </summary> /// <param name="mat"></param> /// <param name="src"></param> /// <param name="dst"></param> public static void AssertCompatible(ICpuFullMatrix mat, ICpuVector src, ICpuVector dst) { // Also check the physical sizes. AssertCompatible(mat); AssertCompatibleCore(mat, src, dst); var m = A(mat); Contracts.Assert(m.ColCountPhy == A(src).Items.Size); Contracts.Assert(m.RowCountPhy == A(dst).Items.Size); }
private static TMatrix A(ICpuFullMatrix x) { AssertCompatible(x); return((TMatrix)x); }