//交换AX=b中向量 b 的元素 template<typename T> voidswap_vect_row(T* vector,int len, int source_row, int dest_row) { T temp_val = 0; temp_val = vector[dest_row - 1]; vector[dest_row - 1] = vector[source_row - 1]; vector[source_row - 1] = temp_val; }
//某行乘以某数 template<typename T> voidmul_row(T* matrix, int row, int col, int source_row, double multiple) { //cout << "第 " << source_row << " 行乘以 " << multiple <<endl; for (int i = 0; i < col; i++) matrix[(source_row - 1) * col + i] *= multiple; }
template<typename T> voidadd_row(T* matrix, int row, int col, int source_row, int dest_row) { for (int i = 0; i < col; ++i) matrix[(dest_row - 1) * col + i] += matrix[(source_row - 1) * col + i]; }
template<typename T> voidadd_vec_row(T* vector, int len, int source_row, int dest_row) { vector[dest_row - 1] += vector[source_row - 1]; }