// load h by w data set into a freshly allocated matrix static MATRIX * load_matrix(OE oe, byte * data, uint h, uint w) { MATRIX * res = new_matrix(oe,h,w); uint row = 0, col = 0; for(row = 0; row < h;++row) { for(col = 0; col < w;++col) { matrix_setentry(res,row,col,data[col+w*row]); } } return res; }
/*! * Build the h by w Van Der Monde matrix on the form: * +----------------------+ * | 1 1 1 ... 1 | * | 1 r r^2 ... 2^{w-1} | * | 1 r^2 r^3 ... 2^{w-2}| * . . * | etc... | * +----------------------+ */ MATRIX * build_nth_matrix(uint h, uint w, byte root) { int i = 0, j = 0; byte curroot = 1; MATRIX * m = new_matrix(h,w); for(i=0;i<h;++i) { byte val = 1; for(j=0;j<w;++j) { matrix_setentry(m,i,j,val); val = multiply(val,curroot); } curroot = multiply(root,curroot); } return m; }