/* * SPQRUtil.cpp * * Created on: Jul 1, 2010 * Author: nikai * Description: the utility functions for SPQR */ #include #include "SPQRUtil.h" using namespace std; #ifdef GT_USE_LAPACK namespace gtsam { /* ************************************************************************* */ long* MakeStairs(Matrix& A) { const long m = A.size1(); const long n = A.size2(); long* Stair = new long[n]; // record the starting pointer of each row double* a[m]; list remained; a[0] = A.data().begin(); for(int i=0; i sorted; list::iterator itRemained; for(j = 0; j < min(m,n); ) { // remove the non-zero rows in the current column for(itRemained = remained.begin(); itRemained!=remained.end(); ) { if (*(a[*itRemained]) != 0) { sorted.push_back(*itRemained); itRemained = remained.erase(itRemained); } else { a[*itRemained]++; itRemained ++; } } // record the stair number Stair[j++] = m - remained.size(); if(remained.empty()) break; } // all the remained columns have maximum stair for (; j::const_iterator itSorted; double* ptr1 = A.data().begin(); double* ptr2 = A_new.data().begin(); int row = 0, sizeOfRow = n * sizeof(double); for(itSorted=sorted.begin(); itSorted!=sorted.end(); itSorted++, row++) memcpy(ptr2+offset[row], ptr1+offset[*itSorted], sizeOfRow); A = A_new; return Stair; } void printColumnMajor(const double* a, const long m, const long n) { for(int i=0; i(m, n, npiv, tol, ntol, fchunk, a, Stair, Rdead, Tau, W, &wscale, &wssq, &cc); long k0 = 0; long j0; memset(A.data().begin(), 0, m*n*sizeof(double)); for(long j=0; j