Eigen  3.3.3
SparseLU_copy_to_ucol.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 /* 
00010  
00011  * NOTE: This file is the modified version of [s,d,c,z]copy_to_ucol.c file in SuperLU 
00012  
00013  * -- SuperLU routine (version 2.0) --
00014  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
00015  * and Lawrence Berkeley National Lab.
00016  * November 15, 1997
00017  *
00018  * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
00019  *
00020  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
00021  * EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
00022  *
00023  * Permission is hereby granted to use or copy this program for any
00024  * purpose, provided the above notices are retained on all copies.
00025  * Permission to modify the code and to distribute modified code is
00026  * granted, provided the above notices are retained, and a notice that
00027  * the code was modified is included with the above copyright notice.
00028  */
00029 #ifndef SPARSELU_COPY_TO_UCOL_H
00030 #define SPARSELU_COPY_TO_UCOL_H
00031 
00032 namespace Eigen {
00033 namespace internal {
00034 
00049 template <typename Scalar, typename StorageIndex>
00050 Index SparseLUImpl<Scalar,StorageIndex>::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep,
00051                                                       BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu)
00052 {  
00053   Index ksub, krep, ksupno; 
00054     
00055   Index jsupno = glu.supno(jcol);
00056   
00057   // For each nonzero supernode segment of U[*,j] in topological order 
00058   Index k = nseg - 1, i; 
00059   StorageIndex nextu = glu.xusub(jcol); 
00060   Index kfnz, isub, segsize; 
00061   Index new_next,irow; 
00062   Index fsupc, mem; 
00063   for (ksub = 0; ksub < nseg; ksub++)
00064   {
00065     krep = segrep(k); k--; 
00066     ksupno = glu.supno(krep); 
00067     if (jsupno != ksupno ) // should go into ucol(); 
00068     {
00069       kfnz = repfnz(krep); 
00070       if (kfnz != emptyIdxLU)
00071       { // Nonzero U-segment 
00072         fsupc = glu.xsup(ksupno); 
00073         isub = glu.xlsub(fsupc) + kfnz - fsupc; 
00074         segsize = krep - kfnz + 1; 
00075         new_next = nextu + segsize; 
00076         while (new_next > glu.nzumax) 
00077         {
00078           mem = memXpand<ScalarVector>(glu.ucol, glu.nzumax, nextu, UCOL, glu.num_expansions); 
00079           if (mem) return mem; 
00080           mem = memXpand<IndexVector>(glu.usub, glu.nzumax, nextu, USUB, glu.num_expansions); 
00081           if (mem) return mem; 
00082           
00083         }
00084         
00085         for (i = 0; i < segsize; i++)
00086         {
00087           irow = glu.lsub(isub); 
00088           glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order
00089           glu.ucol(nextu) = dense(irow); 
00090           dense(irow) = Scalar(0.0); 
00091           nextu++;
00092           isub++;
00093         }
00094         
00095       } // end nonzero U-segment 
00096       
00097     } // end if jsupno 
00098     
00099   } // end for each segment
00100   glu.xusub(jcol + 1) = nextu; // close U(*,jcol)
00101   return 0; 
00102 }
00103 
00104 } // namespace internal
00105 } // end namespace Eigen
00106 
00107 #endif // SPARSELU_COPY_TO_UCOL_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends