From a19e3c80cf8a9e09bf51cca9ea28f9c11a923884 Mon Sep 17 00:00:00 2001 From: David Mayerich Date: Thu, 16 Feb 2017 20:58:03 -0600 Subject: [PATCH] matrix edits for the 2D flow simulation --- stim/biomodels/flow.h | 13 +++++++------ stim/math/matrix.h | 4 ++-- stim/math/matrix_sq.h | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/stim/biomodels/flow.h b/stim/biomodels/flow.h index bdb3c9d..ef05e3d 100644 --- a/stim/biomodels/flow.h +++ b/stim/biomodels/flow.h @@ -118,7 +118,8 @@ namespace stim { Q.resize(n_e); } - void inversion(T** A, int order, T** C) { + /// Calculate the inverse of A and store the result in C + void inversion(T** A, int order, T* C) { #ifdef __CUDACC__ @@ -127,7 +128,7 @@ namespace stim { for (unsigned i = 0; i < order; i++) for (unsigned j = 0; j < order; j++) Aflat[i * order + j] = A[i][j]; - T* Cflat = (T*)malloc(order * order * sizeof(T)); + //T* Cflat = C;// (T*)malloc(order * order * sizeof(T)); // create device pointer T* d_Aflat; // flat original matrix @@ -175,14 +176,14 @@ namespace stim { HANDLE_ERROR(cudaMemcpy(&d_Cflat, d_C, sizeof(T*), cudaMemcpyDeviceToHost)); // copy inverse matrix from device to host - HANDLE_ERROR(cudaMemcpy(Cflat, d_Cflat, order * order * sizeof(T), cudaMemcpyDeviceToHost)); + HANDLE_ERROR(cudaMemcpy(C, d_Cflat, order * order * sizeof(T), cudaMemcpyDeviceToHost)); - for(unsigned i = 0; i < order; i++) - memcpy(C[i], &Cflat[i*order], order * sizeof(T*)); + //for(unsigned i = 0; i < order; i++) + // memcpy(C[i], &Cflat[i*order], order * sizeof(T*)); // clear up free(Aflat); - free(Cflat); + //free(Cflat); HANDLE_ERROR(cudaFree(d_Aflat)); HANDLE_ERROR(cudaFree(d_Cflat)); HANDLE_ERROR(cudaFree(d_A)); diff --git a/stim/math/matrix.h b/stim/math/matrix.h index 533e4e9..d7fd2ef 100644 --- a/stim/math/matrix.h +++ b/stim/math/matrix.h @@ -1,5 +1,5 @@ -#ifndef RTS_MATRIX_H -#define RTS_MATRIX_H +#ifndef STIM_MATRIX_H +#define STIM_MATRIX_H //#include "rts/vector.h" #include diff --git a/stim/math/matrix_sq.h b/stim/math/matrix_sq.h index ee61ca7..dcc20d0 100644 --- a/stim/math/matrix_sq.h +++ b/stim/math/matrix_sq.h @@ -1,5 +1,5 @@ -#ifndef RTS_MATRIX_H -#define RTS_MATRIX_H +#ifndef STIM_MATRIX_SQ_H +#define STIM_MATRIX_SQ_H //#include "rts/vector.h" #include -- libgit2 0.21.4