public ColumnWiseMatrix(string fileName, MathDomain mathDomain) { _buffer = new MemoryTile(0, 0, 0, memorySpace, mathDomain); switch (mathDomain) { case MathDomain.Null: throw new ArgumentNullException(); case MathDomain.Int: { ReadFromBinaryFile <int>(fileName); break; } case MathDomain.Float: { ReadFromBinaryFile <float>(fileName); break; } case MathDomain.Double: { ReadFromBinaryFile <double>(fileName); break; } default: throw new NotImplementedException(); } SetColumnsPointers(); }
public ColumnWiseMatrix(int nRows, int nCols, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float) : base(true, memorySpace, mathDomain) { _buffer = new MemoryTile(0, (uint)nRows, (uint)nCols, memorySpace, mathDomain); ctor(_buffer); SetColumnsPointers(); }
public static void SparseMultiply(MemoryTile A, SparseMemoryTile B, MemoryTile C, int leadingDimensionB, int leadingDimensionC, MatrixOperation bOperation, MatrixOperation cOperation, double alpha) { int err = _SparseMultiplyRaw(A.pointer, B.pointer, C.pointer, B.size, B.nonZeroColumnIndices, B.nNonZeroRows, B.nRows, C.nRows, C.nCols, B.memorySpace, B.mathDomain, (uint)leadingDimensionB, (uint)leadingDimensionC, bOperation, alpha); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_SparseMultiplyRaw", err); } }
public static void AddEqualMatrix(MemoryTile A, MemoryTile B, MatrixOperation aOperation, MatrixOperation bOperation, double alpha, double beta) { int err = _AddEqualMatrixRaw(A.pointer, B.pointer, A.nRows, A.nCols, A.memorySpace, A.mathDomain, aOperation, bOperation, alpha, beta); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_AddEqualMatrixRaw", err); } }
public static void Eye(MemoryTile A) { int err = _EyeRaw(A.pointer, A.nRows, A.memorySpace, A.mathDomain); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_EyeRaw", err); } }
public static void Invert(MemoryTile A, MatrixOperation aOperation) { int err = _InvertRaw(A.pointer, A.nRows, A.nCols, A.memorySpace, A.mathDomain, aOperation); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_InvertRaw", err); } }
public static void CumulativeRowSum(MemoryTile A) { int err = _CumulativeRowSumRaw(A.pointer, A.nRows, A.nCols, A.memorySpace, A.mathDomain); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_CumulativeRowSumRaw", err); } }
public static void KroneckerProduct(MemoryTile A, MemoryBuffer x, MemoryBuffer y, double alpha) { int err = _KroneckerProductRaw(A.pointer, x.pointer, y.pointer, A.nRows, A.nCols, A.memorySpace, A.mathDomain, alpha); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_KroneckerProductRaw", err); } }
public static void Dot(MemoryBuffer y, MemoryTile A, MemoryBuffer x, MatrixOperation aOperation, double alpha, double beta) { int err = _DotRaw(y.pointer, A.pointer, x.pointer, A.nRows, A.nCols, A.memorySpace, A.mathDomain, aOperation, alpha, beta); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_DotRaw", err); } }
public static void Multiply(MemoryTile A, MemoryTile B, MemoryTile C, int leadingDimensionB, int leadingDimensionC, MatrixOperation bOperation, MatrixOperation cOperation, double alpha, double beta) { int err = _MultiplyRaw(A.pointer, B.pointer, C.pointer, B.nRows, C.nRows, C.nCols, A.memorySpace, A.mathDomain, (uint)leadingDimensionB, (uint)leadingDimensionC, bOperation, cOperation, alpha, beta); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_MultiplyRaw", err); } }
private void SetCubesPointers() { uint shift = _buffer.ElementarySize(); for (int i = 0; i < nCubes; i++) { MemoryTile columnBuffer = new MemoryTile(_buffer.pointer + (PtrT)(i * nRows * nCols * shift), (uint)nRows, (uint)nCols, memorySpace, mathDomain); cubes[i] = new ColumnWiseMatrix(columnBuffer); } }
public static int ColumnWiseAbsoluteMaximumIndex(MemoryBuffer argMin, MemoryTile A) { int ret = -1; int err = _ColumnWiseArgAbsMaxRaw(argMin.pointer, A.pointer, A.nRows, A.nCols, A.memorySpace, A.mathDomain); if (err != 0) { Exceptions.CuBlasKernelExceptionFactory.ThrowException("_ColumnWiseArgAbsMaxRaw", err); } return(ret); }
IEnumerator checkTiles(GameObject tile1, GameObject tile2) { //get tile scripts and animators for both tiles MemoryTile firstTile = tile1.GetComponent <MemoryTile>(); MemoryTile secondTile = tile2.GetComponent <MemoryTile>(); Animator firstAnimator = tile1.GetComponent <Animator>(); Animator secondAnimator = tile2.GetComponent <Animator>(); //if the tiles belong to the same pair if (firstTile.pairIndex == secondTile.pairIndex) { //one pair less pairsLeft--; //remove both tiles firstAnimator.SetBool("remove tile", true); secondAnimator.SetBool("remove tile", true); //wait until the effect has ended and destroy the tiles yield return(new WaitForSeconds(1)); Destroy(tile1); Destroy(tile2); } else { //if they're not the same pair flip them back firstAnimator.SetBool("image visible", false); secondAnimator.SetBool("image visible", false); } //end game if there are no pairs left if (pairsLeft == 0) { done(); } }
internal ColumnWiseMatrix(MemoryTile buffer) : base(false, buffer.memorySpace, buffer.mathDomain) { _buffer = buffer; }