Eigen  5.0.1
 
Loading...
Searching...
No Matches
SparseLU_copy_to_ucol.h
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// SPDX-License-Identifier: MPL-2.0
10/*
11
12 * NOTE: This file is the modified version of [s,d,c,z]copy_to_ucol.c file in SuperLU
13
14 * -- SuperLU routine (version 2.0) --
15 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
16 * and Lawrence Berkeley National Lab.
17 * November 15, 1997
18 *
19 * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
20 *
21 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
22 * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
23 *
24 * Permission is hereby granted to use or copy this program for any
25 * purpose, provided the above notices are retained on all copies.
26 * Permission to modify the code and to distribute modified code is
27 * granted, provided the above notices are retained, and a notice that
28 * the code was modified is included with the above copyright notice.
29 */
30#ifndef SPARSELU_COPY_TO_UCOL_H
31#define SPARSELU_COPY_TO_UCOL_H
32
33// IWYU pragma: private
34#include "./InternalHeaderCheck.h"
35
36namespace Eigen {
37namespace internal {
38
53template <typename Scalar, typename StorageIndex>
54Index SparseLUImpl<Scalar, StorageIndex>::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep,
55 BlockIndexVector repfnz, IndexVector& perm_r,
56 BlockScalarVector dense, GlobalLU_t& glu) {
57 Index ksub, krep, ksupno;
58
59 Index jsupno = glu.supno(jcol);
60
61 // For each nonzero supernode segment of U[*,j] in topological order
62 Index k = nseg - 1, i;
63 StorageIndex nextu = glu.xusub(jcol);
64 Index kfnz, isub, segsize;
65 Index new_next, irow;
66 Index fsupc, mem;
67 for (ksub = 0; ksub < nseg; ksub++) {
68 krep = segrep(k);
69 k--;
70 ksupno = glu.supno(krep);
71 if (jsupno != ksupno) // should go into ucol();
72 {
73 kfnz = repfnz(krep);
74 if (kfnz != emptyIdxLU) { // Nonzero U-segment
75 fsupc = glu.xsup(ksupno);
76 isub = glu.xlsub(fsupc) + kfnz - fsupc;
77 segsize = krep - kfnz + 1;
78 new_next = nextu + segsize;
79 while (new_next > glu.nzumax) {
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 for (i = 0; i < segsize; i++) {
87 irow = glu.lsub(isub);
88 glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order
89 glu.ucol(nextu) = dense(irow);
90 dense(irow) = Scalar(0.0);
91 nextu++;
92 isub++;
93 }
94
95 } // end nonzero U-segment
96
97 } // end if jsupno
98
99 } // end for each segment
100 glu.xusub(jcol + 1) = nextu; // close U(*,jcol)
101 return 0;
102}
103
104} // namespace internal
105} // end namespace Eigen
106
107#endif // SPARSELU_COPY_TO_UCOL_H
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:54
Index memXpand(VectorType &vec, Index &maxlen, Index nbElts, MemType memtype, Index &num_expansions)
Definition SparseLU_Memory.h:190