Code covered by the BSD License  

Highlights from
slatec

from slatec by Ben Barrowes
The slatec library converted into matlab functions.

[n,nelt,ia,ja,a,isym,iunit]=dcpplt(n,nelt,ia,ja,a,isym,iunit);
function [n,nelt,ia,ja,a,isym,iunit]=dcpplt(n,nelt,ia,ja,a,isym,iunit);
%***BEGIN PROLOGUE  DCPPLT
%***PURPOSE  Printer Plot of SLAP Column Format Matrix.
%            Routine to print out a SLAP Column format matrix in a
%            'printer plot' graphical representation.
%***LIBRARY   SLATEC (SLAP)
%***CATEGORY  N1
%***TYPE      doubleprecision (SCPPLT-S, DCPPLT-D)
%***KEYWORDS  DIAGNOSTICS, LINEAR SYSTEM, SLAP SPARSE
%***AUTHOR  Seager, Mark K., (LLNL)
%             Lawrence Livermore National Laboratory
%             PO BOX 808, L-60
%             Livermore, CA 94550 (510) 423-3141
%             seager@llnl.gov
%***DESCRIPTION
%
% *Usage:
%     INTEGER N, NELT, IA(NELT), JA(NELT), ISYM, IUNIT
%     doubleprecision A(NELT)
%
%     CALL DCPPLT( N, NELT, IA, JA, A, ISYM, IUNIT )
%
% *Arguments:
% N      :IN       Integer
%         Order of the Matrix.
%         If N>MAXORD, only the leading MAXORD x MAXORD
%         submatrix will be printed.  (Currently MAXORD = 225.)
% NELT   :IN       Integer.
%         Number of non-zeros stored in A.
% IA     :IN       Integer IA(NELT).
% JA     :IN       Integer JA(NELT).
% A      :IN       doubleprecision A(NELT).
%         These arrays should hold the matrix A in the SLAP
%         Column format.  See 'Description', below.
% ISYM   :IN       Integer.
%         Flag to indicate symmetric storage format.
%         If ISYM=0, all non-zero entries of the matrix are stored.
%         If ISYM=1, the matrix is symmetric, and only the lower
%         triangle of the matrix is stored.
% IUNIT  :IN       Integer.
%         Fortran logical I/O device unit number to write the matrix
%         to.  This unit must be connected in a system dependent fashion
%         to a file or the console or you will get a nasty message
%         from the Fortran I/O libraries.
%
% *Description:
%       This routine prints out a SLAP  Column format matrix  to the
%       Fortran logical I/O unit   number  IUNIT.  The  numbers them
%       selves  are not printed  out, but   rather  a one  character
%       representation of the numbers.   Elements of the matrix that
%       are not represented in the (IA,JA,A)  arrays are  denoted by
%       ' ' character (a blank).  Elements of A that are *ZERO* (and
%       hence  should  really not be  stored) are  denoted  by a '0'
%       character.  Elements of A that are *POSITIVE* are denoted by
%       'D' if they are Diagonal elements  and '#' if  they are off
%       Diagonal  elements.  Elements of  A that are *NEGATIVE* are
%       denoted by 'N'  if they  are Diagonal  elements and  '*' if
%       they are off Diagonal elements.
%
%       =================== S L A P Column format ==================
%
%       This routine  requires that  the matrix A  be stored in  the
%       SLAP Column format.  In this format the non-zeros are stored
%       counting down columns (except for  the diagonal entry, which
%       must appear first in each  'column')  and are stored  in the
%       doubleprecision array A.   In other words,  for each column
%       in the matrix put the diagonal entry in  A.  Then put in the
%       other non-zero  elements going down  the column (except  the
%       diagonal) in order.   The  IA array holds the  row index for
%       each non-zero.  The JA array holds the offsets  into the IA,
%       A arrays  for  the  beginning  of each   column.   That  is,
%       IA(JA(ICOL)),  A(JA(ICOL)) points   to the beginning  of the
%       ICOL-th   column    in    IA and   A.      IA(JA(ICOL+1)-1),
%       A(JA(ICOL+1)-1) points to  the  end of the   ICOL-th column.
%       Note that we always have  JA(N+1) = NELT+1,  where N is  the
%       number of columns in  the matrix and NELT  is the number  of
%       non-zeros in the matrix.
%
%       Here is an example of the  SLAP Column  storage format for a
%       5x5 Matrix (in the A and IA arrays '|'  denotes the end of a
%       column):
%
%           5x5 Matrix      SLAP Column format for 5x5 matrix on left.
%                              1  2  3    4  5    6  7    8    9 10 11
%       |11 12  0  0 15|   A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
%       |21 22  0  0  0|  IA:  1  2  5 |  2  1 |  3  5 |  4 |  5  1  3
%       | 0  0 33  0 35|  JA:  1  4  6    8  9   12
%       | 0  0  0 44  0|
%       |51  0 53  0 55|
%
% *Cautions:
%     This routine will attempt to write to the Fortran logical output
%     unit IUNIT, if IUNIT ~= 0.  Thus, the user must make sure that
%     this logical unit is attached to a file or terminal before calling
%     this routine with a non-zero value for IUNIT.  This routine does
%     not check for the validity of a non-zero IUNIT unit number.
%
% *Portability:
%     This routine, as distributed, can generate lines up to 229
%     characters long.  Some Fortran systems have more restricted
%     line lengths.  Change parameter MAXORD and the large number
%     in FORMAT 1010 to reduce this line length.
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  (NONE)
%***REVISION HISTORY  (YYMMDD)
%   871119  DATE WRITTEN
%   881213  Previous REVISION DATE
%   890915  Made changes requested at July 1989 CML Meeting.  (MKS)
%   890922  Numerous changes to prologue to make closer to SLATEC
%           standard.  (FNF)
%   890929  Numerous changes to reduce SP/DP differences.  (FNF)
%   910411  Prologue converted to Version 4.0 format.  (BAB)
%   920511  Added complete declaration section.  (WRB)
%   921007  Replaced hard-wired 225 with parameter MAXORD.  (FNF)
%   921021  Corrected syntax of CHARACTER declaration.  (FNF)
%   921026  Corrected D to E in output format.  (FNF)
%   930701  Updated CATEGORY section.  (FNF, WRB)
%***end PROLOGUE  DCPPLT
%     .. Scalar Arguments ..
%     .. Array Arguments ..
%     .. Parameters ..
persistent chmat i icol irow j jbgn jend maxord nmax ; if isempty(chmat),chmat={};end; 

if isempty(maxord), maxord=225 ; end;
%     .. Local Scalars ..
if isempty(i), i=0; end;
if isempty(icol), icol=0; end;
if isempty(irow), irow=0; end;
if isempty(j), j=0; end;
if isempty(jbgn), jbgn=0; end;
if isempty(jend), jend=0; end;
if isempty(nmax), nmax=0; end;
%     .. Local Arrays ..
if isempty(chmat), chmat=cell(1,maxord); end;
%     .. Intrinsic Functions ..
% intrinsic min , mod , real ::;
%***FIRST EXECUTABLE STATEMENT  DCPPLT
%
%         Set up the character matrix...
%
nmax = fix(min(maxord,n));
for i = 1 : nmax;
chmat{i}(1:nmax) = ' ';
end; i = fix(nmax+1);
for icol = 1 : nmax;
jbgn = fix(ja(icol));
jend = fix(ja(icol+1) - 1);
for j = jbgn : jend;
irow = fix(ia(j));
if( irow<=nmax )
if( isym~=0 )
%         Put in non-sym part as well...
if( a(j)==0.0d0 )
chmat{irow}(icol:icol) = '0';
elseif( a(j)>0.0d0 ) ;
chmat{irow}(icol:icol) = '#';
else;
chmat{irow}(icol:icol) = '*';
end;
end;
if( irow==icol )
%         Diagonal entry.
if( a(j)==0.0d0 )
chmat{irow}(icol:icol) = '0';
elseif( a(j)>0.0d0 ) ;
chmat{irow}(icol:icol) = 'D';
else;
chmat{irow}(icol:icol) = 'N';
end;
%         Off-Diagonal entry
elseif( a(j)==0.0d0 ) ;
chmat{irow}(icol:icol) = '0';
elseif( a(j)>0.0d0 ) ;
chmat{irow}(icol:icol) = '#';
else;
chmat{irow}(icol:icol) = '*';
end;
end;
end; j = fix(jend+1);
end; icol = fix(nmax+1);
%
%         Write out the heading.
writef(iunit,[ '\n ' ,'**** Picture of Column SLAP matrix follows ****', '\n ' ,' N, NELT and Density = ',repmat('%10i',1,2),'%16.7f' ' \n'], n , nelt , real(nelt)./(n.*n));
%
%format ['**** Picture of Column SLAP matrix follows ****'/' N, NELT and Density = ',2I10,d16.7);
for i=(1):(nmax), writef(iunit,[repmat(' ',1,4),repmat(['%1i'] ,1,225) ' \n'],rem(i,10)); end;
%      The following assumes MAXORD<=225.
%format(4x,225(i1));
%
%         Write out the character representations matrix elements.
for irow = 1 : nmax;
writef(iunit,[repmat(' ',1,1),'%3i','%s' ' \n'], irow , chmat{irow}(1:nmax));
%format(1x,i3,a);
end; irow = fix(nmax+1);
return;
%------------- LAST LINE OF DCPPLT FOLLOWS ----------------------------
end
%DECK DCSCAL

Contact us