HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Typedefs | Functions | Variables
mmread.m File Reference

Typedefs

using mmfile = fopen(filename, 'r')
 

Functions

depending on the Matrix Market format indicated by coordinate (coordinate sparse storage)
 
depending on the Matrix Market format indicated by or array (dense array storage). The data will be duplicated % as appropriate if symmetry is indicated in the header. % % Optionally
 
 if (mmfile==-1) disp(filename)
 
 error ('File not found')
 
 if (length(symm)==0) disp(['Not enough words in header line of file '
 
filename disp ('Recognized format:') disp('%%MatrixMarket matrix representation field symmetry') error('Check header line.') end if(~ strcmp(head0
 
filename MatrixMarket error ('Not a valid MatrixMarket header.') end if(~ strcmp(head1
 
filename MatrixMarket matrix disp (['This seems to be a MatrixMarket ', head1,' file.'])
 
 disp ('This function only knows how to read MatrixMarket matrix files.')
 
 disp (' ')
 
 error (' ')
 
while length (commentline) > 0 &commentline(1)
 
end Read size then branch according to sparse or dense format if (strcmp(rep, 'coordinate')) % read matrix given in sparse % coordinate matrix format[sizeinfo
 
 while (count==0) commentline = fgets(mmfile)
 
 if (commentline==-1) error('End-of-file reached before size information was found.') end[sizeinfo
 
 if (count > 0 &count ~=3) error('Invalid size specification line.') end end rows = sizeinfo(1)
 
 fscanf (mmfile,'%f')]
 
 if (size(T) ~=3 *entries) message
 
 disp (message)
 
 error ('Invalid data.')
 
end elseif (strcmp(rep, 'array')) % read matrix given in dense % array(column major) format[sizeinfo
 
 if (strcmp(symm, 'symmetric')|strcmp(symm, 'hermitian')|strcmp(symm, 'skew-symmetric')) for j =1:cols-1
 
 zeros (j, 1)
 
 A (currenti+1:length(A))]
 
id i ()
 
elseif(strcmp(field, 'pattern')) % pattern(makes no sense for dense) disp( 'Matrix type else Unknown matrix type disp ('Matrix type:', field) error('Invalid matrix type specification. Check header against MM documentation.')
 
id appropriate: (diag(A) diag)
 
 elseif (strcmp(symm, 'hermitian')) A
 
 elseif (strcmp(symm, 'skew-symmetric')) A
 
end fclose (mmfile)
 

Variables

 function [A, rows, cols, entries, rep, field, symm]
 
 end
 
 header = fgets(mmfile)
 
if(header==-1) error( 'Empty file.') end % NOTE see note above [head1, header] = strtok(header)
 
 head1 = lower(head1)
 
 rep = lower(rep)
 
 field = lower(field)
 
 symm = lower(symm)
 
end Read through comments
 
end Read through ignoring them commentline = fgets(mmfile)
 
end Read size information
 
end Read size then branch according to sparse or dense format count = sscanf(commentline,'%d%d%d')
 
 cols = sizeinfo(2)
 
 entries = sizeinfo(3)
 
if(strcmp(field, 'real')) % real valued entries T = [T
 
 A = sparse(T(:,1), T(:,2), T(:,3), rows , cols)
 
 currenti = j*rows
 
elseif(strcmp(field, 'complex')) % complx valued entries tmpi = fscanf(mmfile,'%f',1)
 
for j
 
end end If symmetric
 

Typedef Documentation

◆ mmfile

using mmfile = fopen(filename,'r')

Function Documentation

◆ A()

A ( currenti 1:lengthA)

◆ appropriate:()

id appropriate: ( diag(A diag)
virtual

◆ array()

depending on the Matrix Market format indicated by or array ( dense array  storage)

◆ coordinate()

depending on the Matrix Market format indicated by coordinate ( coordinate sparse  storage)

◆ disp() [1/6]

disp ( ' '  )

◆ disp() [2/6]

elseif ( strcmp(field,'pattern')) % pattern (makes no sense for dense) disp('Matrix type else Unknown matrix type disp ( 'Matrix type:'  ,
field   
)

◆ disp() [3/6]

filename disp ( 'Recognized format:'  )

◆ disp() [4/6]

disp ( 'This function only knows how to read MatrixMarket matrix files.'  )

◆ disp() [5/6]

filename MatrixMarket matrix disp ( )

◆ disp() [6/6]

disp ( message  )

◆ elseif() [1/3]

end elseif ( strcmp(rep, 'array')  )

◆ elseif() [2/3]

elseif ( strcmp(symm, 'hermitian')  )

◆ elseif() [3/3]

elseif ( strcmp(symm, 'skew-symmetric')  )

◆ error() [1/4]

error ( ' '  )

◆ error() [2/4]

error ( 'File not found'  )

◆ error() [3/4]

error ( 'Invalid data.'  )

◆ error() [4/4]

filename MatrixMarket error ( 'Not a valid MatrixMarket header.'  )

◆ fclose()

end fclose ( mmfile  )

◆ fscanf()

fscanf ( mmfile  ,
'%f'   
)

◆ i()

id i ( )
staticvirtual

◆ if() [1/7]

if ( commentline  = = -1)

◆ if() [2/7]

if ( count  ,
0 &count = 3 
) = sizeinfo(1)

◆ if() [3/7]

if ( length(symm = = 0)

◆ if() [4/7]

if ( mmfile  = =-1)

◆ if() [5/7]

if ( size(T) ~  = 3 *entries)
Initial value:
= ...
str2mat('Data file does not contain expected amount of data.',...
'Check that number of data lines matches nonzero count.')

◆ if() [6/7]

end Read size then branch according to sparse or dense format if ( strcmp(rep, 'coordinate')  )

◆ if() [7/7]

end if ( strcmp(symm, 'symmetric')|strcmp(symm, 'hermitian')|strcmp(symm, 'skew-symmetric')  ) =1:cols-1

◆ length()

while length ( commentline  ) &

◆ while()

while ( count  = =0) = fgets(mmfile)

◆ zeros()

zeros ( j  ,
 
)

Variable Documentation

◆ A

A = sparse(T(:,1), T(:,2), T(:,3), rows , cols)

◆ above

if (header == -1 ) error('Empty file.') end % NOTE see note above[head1, header] = strtok(header)

◆ cols

cols = sizeinfo(2)

◆ commentline

while commentline = fgets(mmfile)

◆ comments

end Read through comments

◆ count

end count = sscanf(commentline,'%d%d%d')

◆ currenti

end currenti = j*rows

◆ end

end

◆ entries

entries = sizeinfo(3)

◆ field

field = lower(field)

◆ function

function[A, rows, cols, entries, rep, field, symm]
Initial value:
= mmread(filename)
%
% function [A] = mmread(filename)
%
% function [A,rows,cols,entries,rep,field,symm] = mmread(filename)
%
% Reads the contents of the Matrix Market file 'filename'
% into the matrix 'A'. 'A' will be either sparse or full
@ Matrix
Definition: basis.hpp:68

◆ head1

head1 = lower(head1)

◆ header

header = fgets(mmfile)

◆ information

end Read size information

◆ j

for j
Initial value:
=1:entries-1
tmpr = fscanf(mmfile,'%f',1)
fopen(filename, 'r') mmfile
Definition: mmread.m:22
entries
Definition: mmread.m:88
fscanf(mmfile,'%f')]

◆ rep

rep = lower(rep)

◆ symm

symm = lower(symm)

◆ symmetric

end end If symmetric

◆ T

end T = [T

◆ tmpi

tmpi = fscanf(mmfile,'%f',1)