#include #include #include #include #include "quern.h" int QUERN_get_rbfs_column_ordering(int m, int n, const int* A_row_start, const int* A_column_index, int* column_order) { if(m<=0 || n<=0 || !A_row_start || !A_column_index || !column_order) return QUERN_INPUT_ERROR; // get some memory to work in int* work=(int*)std::malloc((n+1+A_row_start[m]+n+n)*sizeof(int)); if(!work) return QUERN_OUT_OF_MEMORY; // figure out number of entries in each column int* column_start=work; std::memset(column_start, 0, (n+1)*sizeof(int)); for(int i=0; i=p; --i){ int j=column_order[i]; // add unmarked neighbour columns of j to ordering for(int k=column_start[j]; k* row=(std::pair*) std::malloc(n*sizeof(std::pair)); if(!row) return QUERN_OUT_OF_MEMORY; // and invert the permutation int* inv=(int*)std::malloc(n*sizeof(int)); if(!inv){ std::free(row); return QUERN_OUT_OF_MEMORY; } for(int i=0; i