Beispiel #1
0
N_Vector Cvode::nvnew(long int n) {
#if PARANEURON
	if (use_partrans_) {
		if (net_cvode_instance->use_long_double_) {
			return N_VNew_NrnParallelLD(0, n, global_neq_);
		}else{
			return N_VNew_Parallel(0, n, global_neq_);
		}
	}
#endif
	if (nctd_ > 1) {
		assert(n == neq_);
		if (!nthsizes_) {
			nthsizes_ = new long int[nrn_nthread];
			for (int i = 0; i < nrn_nthread; ++i) {
				nthsizes_[i] = ctd_[i].nvsize_;
			}
		}
#if 1
		int sum = 0;
		for (int i=0; i < nctd_; ++i) { sum += nthsizes_[i];}
		assert(sum == neq_);
#endif
		if (net_cvode_instance->use_long_double_) {
			return N_VNew_NrnThreadLD(n, nctd_, nthsizes_);
		}else{
			return N_VNew_NrnThread(n, nctd_, nthsizes_);
		}
	}
	if (net_cvode_instance->use_long_double_) {
		return N_VNew_NrnSerialLD(n);
	}else{
		return N_VNew_Serial(n);
	}
}
N_Vector *N_VNewVectorArray_NrnThreadLD(int count, long int length, int nthread, long int* sizes)
{
  N_Vector *vs;
  int j;

  if (count <= 0) return(NULL);

  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
  if(vs == NULL) return(NULL);

  for (j=0; j<count; j++) {
    vs[j] = N_VNew_NrnThreadLD(length, nthread, sizes);
    if (vs[j] == NULL) {
      N_VDestroyVectorArray_NrnThreadLD(vs, j-1);
      return(NULL);
    }
  }

  return(vs);
}