Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/nrutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ float *vector();
/* function definition */


#if 0
void nrerror(char error_text[])
/* Numerical Recipes standard error handler */
{
Expand All @@ -96,6 +97,7 @@ void nrerror(char error_text[])
fprintf(stderr, "...now exiting to system...\n");
exit(1);
}
#endif

float *vector(long nl, long nh)
/* allocate a float vector with subscript range v[nl..nr] */
Expand Down
9 changes: 8 additions & 1 deletion ext/svd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ VALUE decompose(VALUE module, VALUE matrix_ruby, VALUE m_ruby, VALUE n_ruby) {
/* precondition */
if((m*n) != RARRAY_LEN(matrix_ruby)) {
rb_raise(rb_eRangeError, "Size of the array is not equal to m * n");
return;
}else if(m<n){
rb_raise(rb_eRangeError, "m(%d) must be greater than or equal to n(%d)", m, n);
}

/* convert to u matrix */
Expand Down Expand Up @@ -64,3 +65,9 @@ void Init_svd()
VALUE module = rb_define_module("SVD");
rb_define_module_function(module, "decompose", decompose, 3);
}

void nrerror(char error_text[])
/* Numerical Recipes standard error handler */
{
rb_raise(rb_eRuntimeError, "Numerical Recipes run-time error...\n%s\n", error_text);
}