public void Test_BLAS2_SPR() { ClearBuffer(hiMatrixANN); ClearBuffer(hiMatrixAPS); ClearBuffer(hiVectorXN); FillBuffer(hiMatrixANN); ConverToSymmetric(hiMatrixANN, N); FillBuffer(hiVectorXN); diMatrixA = _gpu.Allocate(hiMatrixAPS); diVectorXN = _gpu.CopyToDevice(hiVectorXN); // Lower fill mode PackSymmetricMatrix(hiMatrixANN, hiMatrixAPS, N, cublasFillMode.Lower); _gpu.CopyToDevice(hiMatrixAPS, diMatrixA); _blas.SPR(N, Alpha, diVectorXN, diMatrixA); _gpu.CopyFromDevice(diMatrixA, gpuResultP); for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { double cpuResult = Alpha * hiVectorXN[i] * hiVectorXN[j] + hiMatrixANN[GetIndexColumnMajor(i, j, N)]; Assert.AreEqual(cpuResult, gpuResultP[GetIndexPackedSymmetric(i, j, N, cublasFillMode.Lower)]); } } // Upper fill mode PackSymmetricMatrix(hiMatrixANN, hiMatrixAPS, N, cublasFillMode.Upper); _gpu.CopyToDevice(hiMatrixAPS, diMatrixA); _blas.SPR(N, Alpha, diVectorXN, diMatrixA, cublasFillMode.Upper); _gpu.CopyFromDevice(diMatrixA, gpuResultP); for (int i = 0; i < N; i++) { for (int j = i; j < N; j++) { double cpuResult = Alpha * hiVectorXN[i] * hiVectorXN[j] + hiMatrixANN[GetIndexColumnMajor(i, j, N)]; Assert.AreEqual(cpuResult, gpuResultP[GetIndexPackedSymmetric(i, j, N, cublasFillMode.Upper)]); } } _gpu.FreeAll(); }