ext/slicing.c
void parse_ranges(nmatrix* nmat, VALUE* indices, size_t* lower, size_t* upper){

  for(size_t i = 0; i < nmat->ndims; ++i) {
    //take each indices value and parse it
    //to get the corr start and end index of the range

    size_t a1, b1;

    if(rb_obj_is_kind_of(indices[i], rb_cRange) == Qtrue){

      VALUE range_begin = rb_funcall(indices[i], rb_intern("begin"), 0);
      VALUE range_end = rb_funcall(indices[i], rb_intern("end"), 0);
      VALUE exclude_end = rb_funcall(indices[i], rb_intern("exclude_end?"), 0);

      a1 = NUM2SIZET(range_begin);
      if(range_end == Qnil){ //end-less range
        //assign (size_of_dim - 1) to b1
        b1 = NUM2SIZET(nmat->shape[i]) - 1;
      }
      else{
        b1 = NUM2SIZET(range_end);
      }
      

      if(exclude_end == Qtrue && range_end != Qnil){
        b1--;
      }

    }
    else{
      a1 = b1 = NUM2SIZET(indices[i]);
    }

    if(a1 > b1){
      //raise invalid range error
    }

    if(a1 >= nmat->shape[i] || b1 >= nmat->shape[i]){
      //raise index out of bounds error
    }

    lower[i] = a1, upper[i] = b1;
  }

}
/*
 * converts Range objects to corresponding
 * lower limt and upper limit and put them in size_t varibles
 */
converts Range objects to corresponding
lower limt and upper limit and put them in size_t varibles
converts Range objects to corresponding lower limt and upper limit and put them in size_t varibles
void parse_ranges(nmatrix* nmat, VALUE* indices, size_t* lower, size_t* upper){
  for(size_t i = 0; i < nmat->ndims; ++i) {
    size_t a1, b1;
    if(rb_obj_is_kind_of(indices[i], rb_cRange) == Qtrue){
      VALUE range_begin = rb_funcall(indices[i], rb_intern("begin"), 0);
      VALUE range_end = rb_funcall(indices[i], rb_intern("end"), 0);
      VALUE exclude_end = rb_funcall(indices[i], rb_intern("exclude_end?"), 0);
      a1 = NUM2SIZET(range_begin);
      if(range_end == Qnil){ 
        b1 = NUM2SIZET(nmat->shape[i]) - 1;
      }
      else{
        b1 = NUM2SIZET(range_end);
      }
      if(exclude_end == Qtrue && range_end != Qnil){
        b1--;
      }
    }
    else{
      a1 = b1 = NUM2SIZET(indices[i]);
    }
    if(a1 > b1){
    }
    if(a1 >= nmat->shape[i] || b1 >= nmat->shape[i]){
    }
    lower[i] = a1, upper[i] = b1;
  }
}
void parse_ranges ( nmatrix * nmat , VALUE * indices , size_t * lower , size_t * upper ) { for ( size_t i = 0 ; i < nmat -> ndims ; ++ i ) { size_t a1 , b1 ; if ( rb_obj_is_kind_of ( indices [ i ] , rb_cRange ) == Qtrue ) { VALUE range_begin = rb_funcall ( indices [ i ] , rb_intern ( " " ) , 0 ) ; VALUE range_end = rb_funcall ( indices [ i ] , rb_intern ( " " ) , 0 ) ; VALUE exclude_end = rb_funcall ( indices [ i ] , rb_intern ( " " ) , 0 ) ; a1 = NUM2SIZET ( range_begin ) ; if ( range_end == Qnil ) { b1 = NUM2SIZET ( nmat -> shape [ i ] ) - 1 ; } else { b1 = NUM2SIZET ( range_end ) ; } if ( exclude_end == Qtrue && range_end != Qnil ) { b1 -- ; } } else { a1 = b1 = NUM2SIZET ( indices [ i ] ) ; } if ( a1 > b1 ) { } if ( a1 >= nmat -> shape [ i ] || b1 >= nmat -> shape [ i ] ) { } lower [ i ] = a1 , upper [ i ] = b1 ; } }
converts Range objects to corresponding
 lower limt and upper limit and put them in size_t varibles
converts Range objects to corresponding lower limt and upper limit and put them in size_t varibles
//take each indices value and parse it //to get the corr start and end index of the range //end-less range //assign (size_of_dim - 1) to b1 //raise invalid range error //raise index out of bounds error