Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
SparseLU_pruneL.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 <[email protected]>
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
12 * NOTE: This file is the modified version of [s,d,c,z]pruneL.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_PRUNEL_H
31#define SPARSELU_PRUNEL_H
32
33// IWYU pragma: private
34#include "./InternalHeaderCheck.h"
35
36namespace Eigen {
37namespace internal {
38
55template <typename Scalar, typename StorageIndex>
56void SparseLUImpl<Scalar, StorageIndex>::pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow,
57 const Index nseg, const IndexVector& segrep, BlockIndexVector repfnz,
58 IndexVector& xprune, GlobalLU_t& glu) {
59 // For each supernode-rep irep in U(*,j]
60 Index jsupno = glu.supno(jcol);
61 Index i, irep, irep1;
62 bool movnum, do_prune = false;
63 Index kmin = 0, kmax = 0, minloc, maxloc, krow;
64 for (i = 0; i < nseg; i++) {
65 irep = segrep(i);
66 irep1 = irep + 1;
67 do_prune = false;
68
69 // Don't prune with a zero U-segment
70 if (repfnz(irep) == emptyIdxLU) continue;
71
72 // If a snode overlaps with the next panel, then the U-segment
73 // is fragmented into two parts -- irep and irep1. We should let
74 // pruning occur at the rep-column in irep1s snode.
75 if (glu.supno(irep) == glu.supno(irep1)) continue; // don't prune
76
77 // If it has not been pruned & it has a nonz in row L(pivrow,i)
78 if (glu.supno(irep) != jsupno) {
79 if (xprune(irep) >= glu.xlsub(irep1)) {
80 kmin = glu.xlsub(irep);
81 kmax = glu.xlsub(irep1) - 1;
82 for (krow = kmin; krow <= kmax; krow++) {
83 if (glu.lsub(krow) == pivrow) {
84 do_prune = true;
85 break;
86 }
87 }
88 }
89
90 if (do_prune) {
91 // do a quicksort-type partition
92 // movnum=true means that the num values have to be exchanged
93 movnum = false;
94 if (irep == glu.xsup(glu.supno(irep))) // Snode of size 1
95 movnum = true;
96
97 while (kmin <= kmax) {
98 if (perm_r(glu.lsub(kmax)) == emptyIdxLU)
99 kmax--;
100 else if (perm_r(glu.lsub(kmin)) != emptyIdxLU)
101 kmin++;
102 else {
103 // kmin below pivrow (not yet pivoted), and kmax
104 // above pivrow: interchange the two suscripts
105 std::swap(glu.lsub(kmin), glu.lsub(kmax));
106
107 // If the supernode has only one column, then we
108 // only keep one set of subscripts. For any subscript
109 // intercnahge performed, similar interchange must be
110 // done on the numerical values.
111 if (movnum) {
112 minloc = glu.xlusup(irep) + (kmin - glu.xlsub(irep));
113 maxloc = glu.xlusup(irep) + (kmax - glu.xlsub(irep));
114 std::swap(glu.lusup(minloc), glu.lusup(maxloc));
115 }
116 kmin++;
117 kmax--;
118 }
119 } // end while
120
121 xprune(irep) = StorageIndex(kmin); // Pruning
122 } // end if do_prune
123 } // end pruning
124 } // End for each U-segment
125}
126
127} // end namespace internal
128} // end namespace Eigen
129
130#endif // SPARSELU_PRUNEL_H
Namespace containing all symbols from the Eigen library.
Definition Core:137