SparseLU_copy_to_ucol.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 /*
10 
11  * NOTE: This file is the modified version of [s,d,c,z]copy_to_ucol.c file in SuperLU
12 
13  * -- SuperLU routine (version 2.0) --
14  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
15  * and Lawrence Berkeley National Lab.
16  * November 15, 1997
17  *
18  * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
19  *
20  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
21  * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
22  *
23  * Permission is hereby granted to use or copy this program for any
24  * purpose, provided the above notices are retained on all copies.
25  * Permission to modify the code and to distribute modified code is
26  * granted, provided the above notices are retained, and a notice that
27  * the code was modified is included with the above copyright notice.
28  */
29 #ifndef SPARSELU_COPY_TO_UCOL_H
30 #define SPARSELU_COPY_TO_UCOL_H
31 
32 #include "./InternalHeaderCheck.h"
33 
34 namespace Eigen {
35 namespace internal {
36 
51 template <typename Scalar, typename StorageIndex>
52 Index SparseLUImpl<Scalar,StorageIndex>::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep,
53  BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu)
54 {
55  Index ksub, krep, ksupno;
56 
57  Index jsupno = glu.supno(jcol);
58 
59  // For each nonzero supernode segment of U[*,j] in topological order
60  Index k = nseg - 1, i;
61  StorageIndex nextu = glu.xusub(jcol);
62  Index kfnz, isub, segsize;
63  Index new_next,irow;
64  Index fsupc, mem;
65  for (ksub = 0; ksub < nseg; ksub++)
66  {
67  krep = segrep(k); k--;
68  ksupno = glu.supno(krep);
69  if (jsupno != ksupno ) // should go into ucol();
70  {
71  kfnz = repfnz(krep);
72  if (kfnz != emptyIdxLU)
73  { // Nonzero U-segment
74  fsupc = glu.xsup(ksupno);
75  isub = glu.xlsub(fsupc) + kfnz - fsupc;
76  segsize = krep - kfnz + 1;
77  new_next = nextu + segsize;
78  while (new_next > glu.nzumax)
79  {
80  mem = memXpand<ScalarVector>(glu.ucol, glu.nzumax, nextu, UCOL, glu.num_expansions);
81  if (mem) return mem;
82  mem = memXpand<IndexVector>(glu.usub, glu.nzumax, nextu, USUB, glu.num_expansions);
83  if (mem) return mem;
84 
85  }
86 
87  for (i = 0; i < segsize; i++)
88  {
89  irow = glu.lsub(isub);
90  glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order
91  glu.ucol(nextu) = dense(irow);
92  dense(irow) = Scalar(0.0);
93  nextu++;
94  isub++;
95  }
96 
97  } // end nonzero U-segment
98 
99  } // end if jsupno
100 
101  } // end for each segment
102  glu.xusub(jcol + 1) = nextu; // close U(*,jcol)
103  return 0;
104 }
105 
106 } // namespace internal
107 } // end namespace Eigen
108 
109 #endif // SPARSELU_COPY_TO_UCOL_H
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82