ext/broadcasting.c
VALUE nm_broadcast_to(int argc, VALUE* argv) {
  nmatrix* nmat;
  Data_Get_Struct(argv[0], nmatrix, nmat);

  size_t new_ndims = (size_t)RARRAY_LEN(argv[1]);

  size_t* new_shape = ALLOC_N(size_t, new_ndims);
  for (size_t index = 0; index < new_ndims; index++) {
    new_shape[index] = (size_t)FIX2LONG(RARRAY_AREF(argv[1], index));
  }

  broadcast_matrix(nmat, new_shape, new_ndims);

  return Data_Wrap_Struct(NMatrix, NULL, nm_free, nmat);
}
/*
 * Returns a broadcasted matrix created from
 * input matrix and having given shape
 *
 *
 */
Returns a broadcasted matrix created from
input matrix and having given shape
Returns a broadcasted matrix created from input matrix and having given shape
VALUE nm_broadcast_to(int argc, VALUE* argv) {
  nmatrix* nmat;
  Data_Get_Struct(argv[0], nmatrix, nmat);
  size_t new_ndims = (size_t)RARRAY_LEN(argv[1]);
  size_t* new_shape = ALLOC_N(size_t, new_ndims);
  for (size_t index = 0; index < new_ndims; index++) {
    new_shape[index] = (size_t)FIX2LONG(RARRAY_AREF(argv[1], index));
  }
  broadcast_matrix(nmat, new_shape, new_ndims);
  return Data_Wrap_Struct(NMatrix, NULL, nm_free, nmat);
}
VALUE nm_broadcast_to ( int argc , VALUE * argv ) { nmatrix * nmat ; Data_Get_Struct ( argv [ 0 ] , nmatrix , nmat ) ; size_t new_ndims = ( size_t ) RARRAY_LEN ( argv [ 1 ] ) ; size_t * new_shape = ALLOC_N ( size_t , new_ndims ) ; for ( size_t index = 0 ; index < new_ndims ; index ++ ) { new_shape [ index ] = ( size_t ) FIX2LONG ( RARRAY_AREF ( argv [ 1 ] , index ) ) ; } broadcast_matrix ( nmat , new_shape , new_ndims ) ; return Data_Wrap_Struct ( NMatrix , NULL , nm_free , nmat ) ; }
Returns a broadcasted matrix created from
 input matrix and having given shape
Returns a broadcasted matrix created from input matrix and having given shape