ivan@137: /************************************************************************** ivan@137: * ivan@137: * File name: myblas.c ivan@137: * ivan@137: * Ron Rubinstein ivan@137: * Computer Science Department ivan@137: * Technion, Haifa 32000 Israel ivan@137: * ronrubin@cs ivan@137: * ivan@137: * Version: 1.1 ivan@137: * Last updated: 13.8.2009 ivan@137: * ivan@137: *************************************************************************/ ivan@137: ivan@137: ivan@137: #include "myblas.h" ivan@137: #include ivan@137: ivan@137: ivan@137: /* find maximum of absolute values */ ivan@137: ivan@137: mwIndex maxabs(double c[], mwSize m) ivan@137: { ivan@137: mwIndex maxid=0, k; ivan@137: double absval, maxval = SQR(*c); /* use square which is quicker than absolute value */ ivan@137: ivan@137: for (k=1; k maxval) { ivan@137: maxval = absval; ivan@137: maxid = k; ivan@137: } ivan@137: } ivan@137: return maxid; ivan@137: } ivan@137: ivan@137: ivan@137: /* compute y := alpha*x + y */ ivan@137: ivan@137: void vec_sum(double alpha, double x[], double y[], mwSize n) ivan@137: { ivan@137: mwIndex i; ivan@137: ivan@137: for (i=0; i maxval) { ivan@137: maxval = val; ivan@137: maxid = k; ivan@137: } ivan@137: } ivan@137: return maxid; ivan@137: } ivan@137: ivan@137: ivan@137: /* solve L*x = b */ ivan@137: ivan@137: void backsubst_L(double L[], double b[], double x[], mwSize n, mwSize k) ivan@137: { ivan@137: mwIndex i, j; ivan@137: double rhs; ivan@137: ivan@137: for (i=0; i=1; --i) { ivan@137: rhs = b[i-1]; ivan@137: for (j=i; j=1; --i) { ivan@137: rhs = b[i-1]; ivan@137: for (j=i; j