Main Page | Directories | File List | File Members

lubksb.h

Go to the documentation of this file.
00001 /*
00002    This file belongs to Aeneas. Aeneas is a GNU package released under GPL 3 license.
00003    This code is a simulator for Submicron 3D Semiconductor Devices. 
00004    It implements the Monte Carlo transport in 3D tetrahedra meshes
00005    for the simulation of the semiclassical Boltzmann equation for both electrons.
00006    It also includes all the relevant quantum effects for nanodevices.
00007 
00008    Copyright (C) 2007 Jean Michel Sellier <sellier@dmi.unict.it>
00009  
00010    This program is free software; you can redistribute it and/or modify
00011    it under the terms of the GNU General Public License as published by
00012    the Free Software Foundation; either version 3, or (at your option)
00013    any later version.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License
00021    along with this program. If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 
00024 // Created on : 08 june 2007, Siracusa, Jean Michel Sellier
00025 // Last modified : 08 june 2007, Siracusa, Jean Michel Sellier
00026 
00027 // solves the set of n linear equations A.x = B. Here a[1..n][1..n] is input,
00028 // not as the matrix A but rather as its LU decomposition, determined by the
00029 // routine ludcmp. indx[1..n] is input as the permutation vector returned by
00030 // ludcmp. b[1..n] is input as the right-hand side vector B, and returns with 
00031 // the solution vector X. a, n and indx are not modified by this routine and can
00032 // be left in place for successive calls with different right-hand sides b.
00033 // This routine takes into account the possibility that b will begin with many
00034 // zero elements, so it is efficient for use in matrix inversion.
00035 
00036 {
00037  int i,ii=0,ip,j;
00038  double sum;
00039  
00040  for(i=1;i<=n;i++){
00041     ip=indx[i];
00042     sum=b[ip];
00043     b[ip]=b[i];
00044     if(ii) for(j=ii;j<=i-1;j++) sum-=a[i][j]*b[j];
00045     else if(sum) ii=i;
00046     b[i]=sum;
00047  }
00048  for(i=n;i>=1;i--){
00049     sum=b[i];
00050     for(j=i+1;j<=n;j++) sum-=a[i][j]*b[j];
00051     b[i]=sum/a[i][i];
00052  }
00053 }

© sourcejam.com 2005-2008