コード例 #1
0
ファイル: taucs_ccs_io.c プロジェクト: Wackye/taucs
int
taucs_dtl(ccs_write_ijv)(taucs_ccs_matrix* m, 
			 char* ijvfilename)
{
  int i,ip,j,n;
  taucs_datatype Aij;
  FILE* f;

  f = fopen(ijvfilename , "w");

  if (f == NULL) {
    taucs_printf("taucs_ccs_write_ijv: could not open ijv file %s\n",ijvfilename);
    return -1;
  }

  n = m->n;
  
  for (j=0; j<n; j++) {
    for (ip = (m->colptr)[j]; ip < (m->colptr[j+1]); ip++) {
      i   = (m->rowind)[ip];
      Aij = (m->taucs_values)[ip];

#ifdef TAUCS_CORE_DOUBLE
      fprintf(f,"%d %d %0.17e\n",i+1,j+1,Aij);
      if (i != j && ((m->flags) & TAUCS_SYMMETRIC))
	fprintf(f,"%d %d %0.17e\n",j+1,i+1,Aij);
#endif

#ifdef TAUCS_CORE_SINGLE
      fprintf(f,"%d %d %0.9e\n",i+1,j+1,Aij);
      if (i != j && ((m->flags) & TAUCS_SYMMETRIC))
	fprintf(f,"%d %d %0.9e\n",j+1,i+1,Aij);
#endif
      
#ifdef TAUCS_CORE_DCOMPLEX
      fprintf(f,"%d %d %0.17e+%0.17ei\n",i+1,j+1,taucs_re(Aij),taucs_im(Aij));
      if (i != j && ((m->flags) & TAUCS_SYMMETRIC))
	fprintf(f,"%d %d %0.17e+%0.17ei\n",j+1,i+1,taucs_re(Aij),taucs_re(Aij));
#endif
      
#ifdef TAUCS_CORE_SCOMPLEX
      fprintf(f,"%d %d %0.9e+%0.9ei\n",i+1,j+1,taucs_re(Aij),taucs_im(Aij));
      if (i != j && ((m->flags) & TAUCS_SYMMETRIC))
	fprintf(f,"%d %d %0.9e+%0.9ei\n",j+1,i+1,taucs_re(Aij),taucs_im(Aij));
#endif      

    }
  }

  fclose(f);

  return 0;
} 
コード例 #2
0
ファイル: taucs_vec_base.c プロジェクト: ccowingzitron/inla
void
taucs_dtl(vec_axpby) (int n,
		      taucs_real_datatype a, taucs_datatype * x,
		      taucs_real_datatype b, taucs_datatype * y, taucs_datatype * axpby) {
	int i;

	for (i = 0; i < n; i++) {
#ifdef TAUCS_CORE_COMPLEX
		axpby[i] = taucs_complex_create(a * taucs_re(x[i]) + b * taucs_re(y[i]), a * taucs_im(x[i]) + b * taucs_im(y[i]));
		/*
		 * taucs_re(axpby[i]) = a * taucs_re(x[i]) + b * taucs_re(y[i]); taucs_im(axpby[i]) = a * taucs_im(x[i]) + b *
		 * taucs_im(y[i]); 
		 */
#else
		axpby[i] = a * x[i] + b * y[i];
#endif
	}
}