Functions | |
function | sparseimages (nm, typ) if(strcmp(typ |
function png | set (0,"defaulttextfontname","*") |
endif | if (!isempty(findstr(octave_config_info("DEFS"),"HAVE_COLAMD"))&&!isempty(findstr(octave_config_info("DEFS"),"HAVE_CHOLMOD"))&&!isempty(findstr(octave_config_info("DEFS"),"HAVE_UMFPACK"))) if(strcmp(typ |
endif txt | txtimages (nm, 15, typ) |
else | if (strcmp(nm,"gplot")) gplotimages("gplot" |
elseif (strcmp(nm,"grid")) femimages("grid" | |
else | otherimages (nm, 200, typ) |
endif endif else | sombreroimage (nm, typ) |
endif endfunction function | bury_output () f |
set (f,"visible","off") | |
endfunction function | gplotimages (nm, typ) bury_output() |
gplot (A, xy) print(cstrcat(nm | |
cstrcat ("-d", typ)) bury_output() | |
endfunction function | txtimages (nm, n, typ) a |
if (strcmp(nm,"gplot")||strcmp(nm,"grid")) fid | |
fputs (fid,"\n") | |
fputs (fid,"+---------------------------------+\n") | |
fputs (fid,"| Image unavailable in text mode. |\n") | |
fclose (fid) | |
elseif (strcmp(nm,"spmatrix")) printsparse(a | |
cstrcat ("spmatrix.", typ)) | |
else | if (!isempty(findstr(octave_config_info("DEFS"),"HAVE_COLAMD"))&&!isempty(findstr(octave_config_info("DEFS"),"HAVE_CHOLMOD"))) if(strcmp(nm |
printsparse (r1, cstrcat("spchol.", typ)) | |
elseif (strcmp(nm,"spcholperm"))[r2 | |
printsparse (r2, cstrcat("spcholperm.", typ)) | |
endif endif endif endfunction function | otherimages (nm, n, typ) bury_output() |
if (strcmp(nm,"spmatrix")) spy(a) | |
axis ("ij") print(cstrcat("spmatrix." | |
spy (r1) | |
spy (r2) | |
endif endif endif endfunction function | printsparse (a, nm) fid |
else | fprintf (fid," | ") |
else | fprintf (fid,"--") |
endif endfor | fprintf (fid,"\n") fprintf(fid |
else | fprintf (fid," ") |
endfunction function | femimages (nm, typ) bury_output() |
* | ones (1, 11) |
Sdata (D *(j-1)+(1:D),:) | |
V (D_nodes) | |
idx (D_nodes) | |
Q (N_nodes) | |
V (idx) | |
plot3 (xelems, yelems, velems) | |
view (10, 10) | |
print (cstrcat(nm,".", typ), cstrcat("-d", typ)) bury_output() | |
fputs (fid,"+---------------------------------------+\n") | |
fputs (fid,"| Image unavailable because of a |\n") | |
fputs (fid,"| missing sparse matrix implementation. |\n") | |
title ("Sorry, graphics not available because octave was\\ncompiled without the sparse matrix implementation.") | |
end_unwind_protect endif endfunction function | image_as_txt (nm) fid |
Variables | |
else | typ |
A | |
xy = [0,4,8,6,4,2 | |
else spchol | r1 = chol(a) |
p2 | |
q2 = chol(a) | |
a | |
for | i |
endif for | j |
node_x = ones(5,1)*[1,1.05,1.1,1.2,1.3,1.5,1.7,1.8,1.9,1.95,2] | |
nodes = [node_x(:), node_y(:)] | |
elems = size(node_x) [] | |
for | idx |
__pad0__ | |
endfor | E = size(elems,1) |
N = size(nodes,1) | |
D = size(elems,2) | |
elemx = elems(:,[1,2,3,1])' | |
xelems = reshape( nodes(elemx, 1), 4, E) | |
yelems = reshape( nodes(elemx, 2), 4, E) | |
conductivity = [1*ones(1,16),2*ones(1,48),1*ones(1,16)] | |
D_nodes = [1:5, 51:55] | |
D_value = [10*ones(1,5), 20*ones(1,5)] | |
N_nodes = [] | |
N_value = [] | |
C = sparse((1:D*E), reshape(elems',D*E,1),1, D*E, N) | |
Siidx = floor([0:D*E-1]'/D)*D*ones(1,D) + ones(D*E,1)*(1:D) | |
Sjidx = [1:D*E]'*ones(1,D) | |
Sdata = zeros(D*E,D) | |
dfact = prod(2:(D-1)) | |
const = conductivity(j)*2/dfact/abs(det(a)) | |
endfor | SE = sparse(Siidx,Sjidx,Sdata) |
S = C'* SE *C | |
V = zeros(N,1) | |
Q = zeros(N,1) | |
velems = reshape( V(elemx), 4, E) | |
sz = size(xelems,2) | |
endif endfunction function txt | fid = fopen (sprintf ("%s.txt", nm), "wt") |
return | |
x = y = linspace (-8, 8, 41)' | |
r = meshgrid (x, y) sqrt (xx .^ 2 + yy .^ 2) + eps | |
z = sin (r) ./ r | |
unwind_protect | mesh (x, y, z) |
axis | ( | "ij" | ) |
endif endfunction function bury_output | ( | ) |
cstrcat | ( | "spmatrix." | , | |
typ | ||||
) |
cstrcat | ( | "-d" | , | |
typ | ||||
) |
elseif | ( | strcmp(nm,"spcholperm") | ) |
elseif | ( | strcmp(nm,"spmatrix") | ) |
elseif | ( | strcmp(nm,"grid") | ) |
fclose | ( | fid | ) |
endfunction function femimages | ( | nm | , | |
typ | ||||
) |
fprintf | ( | fid | , | |
"\n" | ||||
) |
fputs | ( | fid | , | |
"| missing sparse matrix implementation. |\n" | ||||
) |
fputs | ( | fid | , | |
"| Image unavailable because of a |\n" | ||||
) |
fputs | ( | fid | , | |
"+---------------------------------------+\n" | ||||
) |
fputs | ( | fid | , | |
"+---------------------------------+\n" | ||||
) |
fputs | ( | fid | , | |
"\n" | ||||
) |
gplot | ( | A | , | |
xy | ||||
) |
endfunction function gplotimages | ( | nm | , | |
typ | ||||
) |
idx | ( | D_nodes | ) |
if | ( | strcmp(nm,"spmatrix") | ) |
else if | ( | ! | isemptyfindstr(octave_config_info("DEFS"),"HAVE_COLAMD"))&&!isempty(findstr(octave_config_info("DEFS"),"HAVE_CHOLMOD") | ) |
if | ( | strcmp(nm,"gplot")||strcmp(nm,"grid") | ) |
else if | ( | strcmp(nm,"gplot") | ) |
endif if | ( | ! | isemptyfindstr(octave_config_info("DEFS"),"HAVE_COLAMD"))&&!isempty(findstr(octave_config_info("DEFS"),"HAVE_CHOLMOD"))&&!isempty(findstr(octave_config_info("DEFS"),"HAVE_UMFPACK") | ) |
end_unwind_protect endif endfunction function image_as_txt | ( | nm | ) |
* ones | ( | 1 | , | |
11 | ||||
) |
( | cstrcat(nm,".", typ) | , | ||
cstrcat("-d", typ) | ||||
) |
endif endif endif endfunction function printsparse | ( | a | , | |
nm | ||||
) |
printsparse | ( | r2 | , | |
cstrcat("spcholperm.", typ) | ||||
) |
printsparse | ( | r1 | , | |
cstrcat("spchol.", typ) | ||||
) |
Q | ( | N_nodes | ) |
Sdata | ( | D * | j-1)+(1:D, | |
: | ||||
) |
set | ( | f | , | |
"visible" | , | |||
"off" | ||||
) |
function png set | ( | 0 | , | |
"defaulttextfontname" | , | |||
"*" | ||||
) |
spy | ( | r2 | ) |
spy | ( | r1 | ) |
title | ( | " | Sorry, | |
graphics not available because octave was\\ncompiled without the sparse matrix implementation." | ||||
) |
endfunction function txtimages | ( | nm | , | |
n | , | |||
typ | ||||
) |
V | ( | idx | ) |
V | ( | D_nodes | ) |
view | ( | 10 | , | |
10 | ||||
) |
test try clear a a |
A |
Initial value:
sparse ([2,6,1,3,2,4,3,5,4,6,1,5], [1,1,2,2,3,3,4,4,5,5,6,6], 1, 6, 6)
conductivity = [1*ones(1,16),2*ones(1,48),1*ones(1,16)] |
const = conductivity(j)*2/dfact/abs(det(a)) |
D_nodes = [1:5, 51:55] |
D_value = [10*ones(1,5), 20*ones(1,5)] |
endif endfunction function txt fid = fopen (sprintf ("%s.txt", nm), "wt") |
unwind_protect mesh(x, y, z) |
F77_RET_T octave_idx_type const octave_idx_type & N = size(nodes,1) |
N_nodes = [] |
N_value = [] |
node_x = ones(5,1)*[1,1.05,1.1,1.2,1.3,1.5,1.7,1.8,1.9,1.95,2] |
Q = zeros(N,1) |
q2 = chol(a) |
r = meshgrid (x, y) sqrt (xx .^ 2 + yy .^ 2) + eps |
return |
sz = size(xelems,2) |
V = zeros(N,1) |
x = y = linspace (-8, 8, 41)' |
xy = [0,4,8,6,4,2 |
z = sin (r) ./ r |