Main Page | Directories | File List | File Members

sprsin.h

Go to the documentation of this file.
00001 /*
00002    This file belongs to Aeneas. Aeneas is a GNU package released under GPL 3.
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 : 06 june 2007, Siracusa, Jean Michel Sellier
00025 // Last modified : 16 september 2007, Siracusa, Jean Michel Sellier
00026 
00027 // Converts a square matrix A[1..n][1..n] into a row-indexed sparse storage
00028 // mode. Only elements of A with magnitude >= thresh are retained. Output is
00029 // in two linear arrays with dimension nmax (an input parameter): 
00030 // sa[1..n][1..n] contains array values, indexed by ija[1..]. 
00031 // The number of elements filled of sa and ija on output are both
00032 // ija[ija[1]-1]-1.
00033 
00034 {
00035  int i,j;
00036  int n=Ng;
00037  int nmax=100*Ne;
00038  
00039  int k;
00040  
00041  for(j=1;j<=n;j++){
00042    sa[j]=A[j*Ng+j]; // store diagonal elements
00043 //   printf("A[%d][%d]=%g *** %g\n",j,j,A[j*Ng+j],sa[j]);
00044  }
00045  ija[1]=n+2;
00046  k=n+1;
00047  for(i=1;i<=n;i++){
00048    for(j=1;j<=n;j++){
00049 //     if(fabs(A[i*Ng+j])!=0.0) printf("fabs(A[%d][%d]=%g\n",i,j,A[i*Ng+j]);
00050      if(fabs(A[i*Ng+j])>=thresh && i!=j){
00051        if(++k>nmax){
00052         printf("srpsin error! nmax too small, please increase it...\n");
00053         exit(0);
00054        }
00055        sa[k]=A[i*Ng+j];
00056 //       printf("A[%d][%d]=%g   k = %d\n",i,j,sa[k],k);
00057        ija[k]=j;
00058      }
00059    }
00060    ija[i+1]=k+1;
00061  }
00062 }

© sourcejam.com 2005-2008