Example #1
0
gf2matrix *extract_region(gf2matrix *dest, const gf2matrix *src, int start_row,
		int start_col, int row_count, int col_count)
{
	if (!src)
		return NULL;
	return mzd_submatrix(dest, src, start_row, start_col,
			start_row + row_count, start_col + col_count);
}
Example #2
0
/*
 * Class:     m4rjni_Mzd
 * Method:    m4ri_submatrix
 * Signature: (JJIIII)J
 */
JNIEXPORT jlong JNICALL Java_m4rjni_Mzd_m4ri_1submatrix(JNIEnv *env, jobject obj, jlong Sptr, jlong Mptr, jint lowr, jint lowc, jint highr, jint highc) {
  mzd_t *S = NULL;
  mzd_t *M = (mzd_t*)Mptr;
  if (lowr<0 || lowc<0 || lowr>=M->nrows || lowc>=M->nrows) {
    printf("ERROR: Java_m4rjni_Mzd_m4ri_1submatrix() - invalid indices passed in\n");
    return 0;
  }

  if (Sptr != 0) {
    if ((highr-lowr)<0 || (highr-lowr)>=S->nrows || (highc-lowc)<0 || (highc-lowc)>=S->ncols) {
      printf("ERROR: Java_m4rjni_Mzd_m4ri_1submatrix() - invalid indices passed in\n");
      return 0;
    }
    S = (mzd_t*)Sptr;
  }

  //printf("about to call mzd_submatrix()\n\n");
  return (jlong) mzd_submatrix(S, M, lowr, lowc, highr, highc);
}