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 // IWYU pragma: private
33 #include "./InternalHeaderCheck.h"
34 
35 namespace Eigen {
36 namespace internal {
37 
52 template <typename Scalar, typename StorageIndex>
54  BlockIndexVector repfnz, IndexVector& perm_r,
55  BlockScalarVector dense, GlobalLU_t& glu) {
56  Index ksub, krep, ksupno;
57 
58  Index jsupno = glu.supno(jcol);
59 
60  // For each nonzero supernode segment of U[*,j] in topological order
61  Index k = nseg - 1, i;
62  StorageIndex nextu = glu.xusub(jcol);
63  Index kfnz, isub, segsize;
64  Index new_next, irow;
65  Index fsupc, mem;
66  for (ksub = 0; ksub < nseg; ksub++) {
67  krep = segrep(k);
68  k--;
69  ksupno = glu.supno(krep);
70  if (jsupno != ksupno) // should go into ucol();
71  {
72  kfnz = repfnz(krep);
73  if (kfnz != emptyIdxLU) { // 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  mem = memXpand<ScalarVector>(glu.ucol, glu.nzumax, nextu, UCOL, glu.num_expansions);
80  if (mem) return mem;
81  mem = memXpand<IndexVector>(glu.usub, glu.nzumax, nextu, USUB, glu.num_expansions);
82  if (mem) return mem;
83  }
84 
85  for (i = 0; i < segsize; i++) {
86  irow = glu.lsub(isub);
87  glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order
88  glu.ucol(nextu) = dense(irow);
89  dense(irow) = Scalar(0.0);
90  nextu++;
91  isub++;
92  }
93 
94  } // end nonzero U-segment
95 
96  } // end if jsupno
97 
98  } // end for each segment
99  glu.xusub(jcol + 1) = nextu; // close U(*,jcol)
100  return 0;
101 }
102 
103 } // namespace internal
104 } // end namespace Eigen
105 
106 #endif // SPARSELU_COPY_TO_UCOL_H
int i
Definition: BiCGSTAB_step_by_step.cpp:9
SCALAR Scalar
Definition: bench_gemm.cpp:45
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:264
Index copy_to_ucol(const Index jcol, const Index nseg, IndexVector &segrep, BlockIndexVector repfnz, IndexVector &perm_r, BlockScalarVector dense, GlobalLU_t &glu)
Performs numeric block updates (sup-col) in topological order.
Definition: SparseLU_copy_to_ucol.h:53
char char char int int * k
Definition: level2_impl.h:374
@ USUB
Definition: SparseLU_Structs.h:77
@ UCOL
Definition: SparseLU_Structs.h:77
@ emptyIdxLU
Definition: SparseLU_Memory.h:41
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49
Definition: SparseLU_Structs.h:80
IndexVector usub
Definition: SparseLU_Structs.h:91
IndexVector xsup
Definition: SparseLU_Structs.h:82
Index nzumax
Definition: SparseLU_Structs.h:93
Index num_expansions
Definition: SparseLU_Structs.h:95
IndexVector supno
Definition: SparseLU_Structs.h:83
IndexVector lsub
Definition: SparseLU_Structs.h:85
IndexVector xusub
Definition: SparseLU_Structs.h:92
IndexVector xlsub
Definition: SparseLU_Structs.h:87
ScalarVector ucol
Definition: SparseLU_Structs.h:90