예제 #1
0
static VALUE rb_dirac_anticommute(VALUE obj, VALUE mm1, VALUE mm2)
{
  gsl_matrix_complex *m1, *m2;
  gsl_matrix_complex *mnew1, *mnew2;
  CHECK_MATRIX_COMPLEX(mm1);
  CHECK_MATRIX_COMPLEX(mm2);
  Data_Get_Struct(mm1, gsl_matrix_complex, m1);
  Data_Get_Struct(mm2, gsl_matrix_complex, m2);
  mnew1 = gsl_matrix_complex_alloc(m1->size1, m1->size2);
  mnew2 = gsl_matrix_complex_alloc(m1->size1, m1->size2);
  gsl_matrix_complex_mul(mnew1, m1, m2);
  gsl_matrix_complex_mul(mnew2, m2, m1);
  gsl_matrix_complex_add(mnew1, mnew2);
  gsl_matrix_complex_free(mnew2);
  return Data_Wrap_Struct(cgsl_matrix_complex, 0, gsl_matrix_complex_free,
                          mnew1);
}
예제 #2
0
파일: dirac.c 프로젝트: Fudge/rb-gsl
static void define_gamma(VALUE module)
{
  size_t i;
  char name[7];
  gsl_complex z;
  for (i = 1; i <= 3; i++) {
    Gamma[i] = gsl_matrix_complex_calloc(4, 4);
    gsl_matrix_complex_mul(Gamma[i], Beta, Alpha[i-1]);
    VGamma[i] = Data_Wrap_Struct(cGamma, 0, 
			    gsl_matrix_complex_free, Gamma[i]);
    sprintf(name, "Gamma%d", (int) i);
    rb_define_const(module, name, VGamma[i]);
  }
  Gamma[4] = gsl_matrix_complex_calloc(4, 4);
  z.dat[0] = 1.0; z.dat[1] = 0.0;
  gsl_matrix_complex_set(Gamma[4], 0, 2, z);
  gsl_matrix_complex_set(Gamma[4], 1, 3, z);
  gsl_matrix_complex_set(Gamma[4], 2, 0, z);
  gsl_matrix_complex_set(Gamma[4], 3, 1, z);
  VGamma[4] = Data_Wrap_Struct(cGamma, 0, 
			  gsl_matrix_complex_free, Gamma[4]);
  rb_define_const(module, "Gamma5", VGamma[4]);
}