2012-05-25 18:17:57 +02:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
|
|
|
|
|
//
|
|
|
|
|
// Eigen is free software; you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
|
// version 3 of the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Alternatively, you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2 of
|
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License and a copy of the GNU General Public License along with
|
|
|
|
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
* NOTE: This file is the modified version of dsnode_bmod.c file in SuperLU
|
|
|
|
|
|
|
|
|
|
* -- SuperLU routine (version 3.0) --
|
|
|
|
|
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
|
|
|
|
|
* and Lawrence Berkeley National Lab.
|
|
|
|
|
* October 15, 2003
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 1994 by Xerox Corporation. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
|
|
|
|
|
* EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted to use or copy this program for any
|
|
|
|
|
* purpose, provided the above notices are retained on all copies.
|
|
|
|
|
* Permission to modify the code and to distribute modified code is
|
|
|
|
|
* granted, provided the above notices are retained, and a notice that
|
|
|
|
|
* the code was modified is included with the above copyright notice.
|
|
|
|
|
*/
|
2012-06-11 18:52:26 +02:00
|
|
|
namespace internal {
|
2012-05-25 18:17:57 +02:00
|
|
|
#ifndef SPARSELU_SNODE_BMOD_H
|
|
|
|
|
#define SPARSELU_SNODE_BMOD_H
|
2012-06-11 18:52:26 +02:00
|
|
|
template <typename Index, typename ScalarVector>
|
|
|
|
|
int SparseLU::LU_dsnode_bmod (const Index jcol, const Index jsupno, const Index fsupc,
|
|
|
|
|
ScalarVector& dense, ScalarVector& tempv, LU_GlobalLu_t& Glu)
|
2012-05-25 18:17:57 +02:00
|
|
|
{
|
2012-06-11 18:52:26 +02:00
|
|
|
typedef typename Matrix<Index, Dynamic, Dynamic> IndexVector;
|
|
|
|
|
IndexVector& lsub = Glu.lsub; // Compressed row subscripts of ( rectangular supernodes ??)
|
|
|
|
|
IndexVector& xlsub = Glu.xlsub; // xlsub[j] is the starting location of the j-th column in lsub(*)
|
|
|
|
|
ScalarVector& lusup = Glu.lusup; // Numerical values of the rectangular supernodes
|
|
|
|
|
IndexVector& xlusup = Glu.xlusup; // xlusup[j] is the starting location of the j-th column in lusup(*)
|
2012-05-25 18:17:57 +02:00
|
|
|
|
|
|
|
|
int nextlu = xlusup(jcol); // Starting location of the next column to add
|
2012-05-30 18:09:26 +02:00
|
|
|
int irow, isub;
|
2012-05-25 18:17:57 +02:00
|
|
|
// Process the supernodal portion of L\U[*,jcol]
|
2012-05-30 18:09:26 +02:00
|
|
|
for (isub = xlsub(fsupc); isub < xlsub(fsupc+1); isub++)
|
2012-05-25 18:17:57 +02:00
|
|
|
{
|
|
|
|
|
irow = lsub(isub);
|
|
|
|
|
lusup(nextlu) = dense(irow);
|
|
|
|
|
dense(irow) = 0;
|
|
|
|
|
++nextlu;
|
|
|
|
|
}
|
|
|
|
|
xlusup(jcol + 1) = nextlu; // Initialize xlusup for next column ( jcol+1 )
|
|
|
|
|
|
|
|
|
|
if (fsupc < jcol ){
|
|
|
|
|
int luptr = xlusup(fsupc); // points to the first column of the supernode
|
|
|
|
|
int nsupr = xlsub(fsupc + 1) -xlsub(fsupc); //Number of rows in the supernode
|
|
|
|
|
int nsupc = jcol - fsupc; // Number of columns in the supernodal portion of L\U[*,jcol]
|
|
|
|
|
int ufirst = xlusup(jcol); // points to the beginning of column jcol in supernode L\U(jsupno)
|
|
|
|
|
|
|
|
|
|
int nrow = nsupr - nsupc; // Number of rows in the off-diagonal blocks
|
2012-05-29 17:55:38 +02:00
|
|
|
|
2012-05-25 18:17:57 +02:00
|
|
|
// Solve the triangular system for U(fsupc:jcol, jcol) with L(fspuc..., fsupc:jcol)
|
2012-05-30 18:09:26 +02:00
|
|
|
Map<Matrix<Scalar,Dynamic,Dynamic>,0,OuterStride<> > A( &(lusup.data()[luptr]), nsupc, nsupc, OuterStride<>(nsupr) );
|
|
|
|
|
Map<Matrix<Scalar,Dynamic,1> > u(&(lusup.data()[ufirst]), nsupc);
|
|
|
|
|
u = A.triangularView<Lower>().solve(u);
|
2012-05-29 17:55:38 +02:00
|
|
|
|
2012-05-25 18:17:57 +02:00
|
|
|
// Update the trailing part of the column jcol U(jcol:jcol+nrow, jcol) using L(jcol:jcol+nrow, fsupc:jcol) and U(fsupc:jcol)
|
2012-05-30 18:09:26 +02:00
|
|
|
new (&A) Map<Matrix<Scalar,Dynamic,Dynamic>,0,OuterStride<> > ( &(lusup.data()[luptr+nsupc]), nrow, nsupc, OuterStride<>(nsupr) );
|
|
|
|
|
Map<Matrix<Scalar,Dynamic,1> > l(&(lusup.data()[ufirst+nsupc], nsupc);
|
|
|
|
|
l = l - A * u;
|
2012-05-25 18:17:57 +02:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2012-06-11 18:52:26 +02:00
|
|
|
} // End namespace internal
|
2012-05-25 18:17:57 +02:00
|
|
|
#endif
|