src/functions.c
// lgamma, or log(gamma(x)) - we need the suffix py because the lgamma function
// is defined in math.h
lgamma, or log(gamma(x)) - we need the suffix py because the lgamma function
is defined in math.h
lgamma or log ( gamma ( x )) - we need the suffix py because the lgamma function is defined in math . h
int lgamma_py(THFloatTensor *input, THFloatTensor *output) {
  float *input_data, *output_data;
  input_data = THFloatTensor_data(input);
  output_data = THFloatTensor_data(output);
  int input_strideHeight = input->stride[0];
  int input_strideWidth = input->stride[1];
  int output_strideHeight = output->stride[0];
  int output_strideWidth = output->stride[1];
  int height = input->size[0];
  int width = input->size[1];
  if (input->nDimension != 2) {
    printf("Warning: lgamma is only implemented for 2-dimensional vectors\n");
  }
  for (int x = 0; x < width; x++) {
    for (int y = 0; y < height; y++) {
      const int out_address = x * output_strideWidth + y * output_strideHeight;
      const int in_address = x * input_strideWidth + y * input_strideHeight;
      output_data[out_address] = lgammaf(input_data[in_address]);
    }
  }
  return 1;
}
int lgamma_py ( THFloatTensor * input , THFloatTensor * output ) { float * input_data , * output_data ; input_data = THFloatTensor_data ( input ) ; output_data = THFloatTensor_data ( output ) ; int input_strideHeight = input -> stride [ 0 ] ; int input_strideWidth = input -> stride [ 1 ] ; int output_strideHeight = output -> stride [ 0 ] ; int output_strideWidth = output -> stride [ 1 ] ; int height = input -> size [ 0 ] ; int width = input -> size [ 1 ] ; if ( input -> nDimension != 2 ) { printf ( " \n " ) ; } for ( int x = 0 ; x < width ; x ++ ) { for ( int y = 0 ; y < height ; y ++ ) { const int out_address = x * output_strideWidth + y * output_strideHeight ; const int in_address = x * input_strideWidth + y * input_strideHeight ; output_data [ out_address ] = lgammaf ( input_data [ in_address ] ) ; } } return 1 ; }
lgamma, or log(gamma(x)) - we need the suffix py because the lgamma function
is defined in math.h
lgamma or log ( gamma ( x )) - we need the suffix py because the lgamma function is defined in math . h