86#include "rheolef/linalg.h"
94struct log10_abs_or_zero {
95 T operator()(
T x) {
return ((x ==
T(0.)) ?
T(0.) : log10(xabs(x))); }
106 bool logscale = iorheo::getlogscale(s);
107 bool color = iorheo::getcolor(s);
111 const char title [256] =
"";
114 const int ptitle = 0;
120 const T paperx = 21.0;
124 int maxdim = max(
a.nrow(),
a.ncol());
128 T lrmrgn = (paperx-size)/2.0;
134 T scfct = size*u2dot/
m;
140 const T fnstit = 0.5;
141 int ltit = strlen(title);
145 const T ytitof = 1.0;
148 T ytit = botmrgn + size*int(
a.nrow())/
T(
m) +
T(ytitof);
151 T xl = lrmrgn*u2dot - scfct*frlw/2;
152 T xr = (lrmrgn+size)*u2dot + scfct*frlw/2;
153 T yb = botmrgn*u2dot - scfct*frlw/2;
155 T yt = (botmrgn+size*int(
a.nrow())/
T(
m))*u2dot + scfct*frlw/2.;
158 yt = yt + (ytitof+fnstit*0.70)*u2dot;
168 if (ptitle == 0 && ltit > 0) {
169 ytit = botmrgn + fnstit*0.3;
170 botmrgn = botmrgn + ytitof + fnstit*0.7;
175 s <<
"%!PS-Adobe-2.0\n";
176 s <<
"%%Creator: sparskit++ 1.0, 1997, Computer Modern Artists\n";
177 s <<
"%%Title: sparskit++ CSR matrix\n";
178 s <<
"%%BoundingBox: " << xl <<
" " << yb <<
" " << xr <<
" " << yt << std::endl;
179 s <<
"%%EndComments\n";
180 s <<
"/cm {72 mul 2.54 div} def\n";
181 s <<
"/mc {72 div 2.54 mul} def\n";
182 s <<
"/pnum { 72 div 2.54 mul 20 string\n";
183 s <<
"cvs print ( ) print} def\n";
184 s <<
"/Cshow {dup stringwidth pop -2 div 0 rmoveto show} def\n";
190 s <<
"/Helvetica findfont " << fnstit <<
" cm scalefont setfont \n";
191 s << xtit <<
" cm " << ytit <<
" cm moveto\n";
192 s <<
"(" << title <<
") Cshow\n";
194 s << lrmrgn <<
" cm " << botmrgn <<
" cm translate\n";
195 s << size <<
" cm " <<
m <<
" div dup scale\n";
198 s << frlw <<
" setlinewidth\n";
201 s <<
a.ncol()+1 <<
" " << 0 <<
" lineto\n";
202 s <<
a.ncol()+1 <<
" " <<
a.nrow()+1 <<
" lineto\n";
203 s << 0 <<
" " <<
a.nrow()+1 <<
" lineto\n";
204 s <<
"closepath stroke\n";
206 s <<
"1 1 translate\n";
207 s <<
"0.8 setlinewidth\n";
208 s <<
"/p {moveto 0 -.40 rmoveto \n";
209 s <<
" 0 .80 rlineto stroke} def\n";
215 const int ncolor = 100;
219 T inf = std::numeric_limits<T>::max();
220 log10_abs_or_zero<T>
filter;
223 max_ = select_op_value (
a,
a+
a.nnz(), -inf, std::greater<T>(),
filter);
224 min_ = select_op_value (
a,
a+
a.nnz(), inf, std::less<T>(),
filter);
226 max_ = select_max(
a,
a+
a.nnz(), -inf);
227 min_ = select_min(
a,
a+
a.nnz(), inf);
229 palette tab = palette(min_, max_, ncolor);
230 tab.postscript_print_color_def (s);
233 for (Index i = 0; i <
a.nrow(); i++)
234 for (Index k = ia [i]; k < ia [i+1]; k++) {
237 if (logscale) value =
filter(value);
238 int ic = tab.color_index(value);
239 s <<
"c" << ic <<
" "
241 <<
a.nrow()-i-1 <<
" p\n";
250 s << j <<
" " <<
a.nrow()-i-1 <<
" p\n";
263 derr <<
"csr: usage: csr "
273 check_macro (communicator().size() == 1,
"csr: command may be used as mono-process only");
274 if (argc <= 1)
usage();
275 bool have_file =
false;
276 typedef enum {
mtx,
ml, ps} out_format_type;
277 out_format_type out_format = ps;
280 for (
int i = 1; i < argc; i++) {
281 if (strcmp (argv[i],
"-ps") == 0) out_format = ps;
282 else if (strcmp (argv[i],
"-matlab") == 0) out_format =
ml;
283 else if (strcmp (argv[i],
"-mtx") == 0) out_format =
mtx;
284 else if (strcmp (argv[i],
"-name") == 0) {
285 if (i == argc-1) { std::cerr <<
"csr -name: option argument missing" << std::endl;
usage(); }
288 else if (strcmp (argv[i],
"-") == 0) filename =
"-";
289 else if (argv[i][0] ==
'-')
usage();
295 if (filename ==
"" || filename ==
"-") {
301 if (out_format ==
ml) {
303 }
else if (out_format == ps) {
305 }
else if (out_format ==
mtx) {
312 cout <<
hb << setbasename(
"a");
314 bool get_rhs =
false;
319 for (
int i = 1; i < argc; i++) {
320 if (strcmp (argv[i],
"-transpose-in") == 0) cin >> transpose;
321 else if (strcmp (argv[i],
"-notranspose-in") == 0) cin >> notranspose;
322 else if (strcmp (argv[i],
"-input-hb") == 0) cin >>
hb;
323 else if (strcmp (argv[i],
"-input-mm") == 0) cin >>
matrix_market;
333 for (
int i = 1; i < argc; i++) {
335 if (strcmp (argv[i],
"-hb") == 0) cout <<
hb;
336 else if (strcmp (argv[i],
"-mm") == 0) cout <<
matrix_market;
337 else if (strcmp (argv[i],
"-ml") == 0) cout <<
ml;
338 else if (strcmp (argv[i],
"-matlab") == 0) cout <<
matlab;
339 else if (strcmp (argv[i],
"-sparse-matlab") == 0) cout << sparse_matlab;
340 else if (strcmp (argv[i],
"-ps") == 0) cout << ps;
341 else if (strcmp (argv[i],
"-dump") == 0) cout <<
dump;
343 else if (strcmp (argv[i],
"-tril") == 0 ||
344 strcmp (argv[i],
"-triu") == 0) {
348 if (isdigit(argv[i+1][0]))
350 else if (argv[i+1][0] ==
'-' &&
351 isdigit(argv[i+1][1]))
352 k = - atoi(argv[++i]+1);
354 if (strcmp (argv[io],
"-tril") == 0)
a = tril(
a,k);
357 else if (strcmp (argv[i],
"-gibbs") == 0) {
358 permutation
p = gibbs(
a);
361 else if (strcmp (argv[i],
"-rhs") == 0) {
365 else if (strcmp (argv[i],
"-logscale") == 0) cout << logscale;
366 else if (strcmp (argv[i],
"-nologscale") == 0) cout << nologscale;
367 else if (strcmp (argv[i],
"-color") == 0) cout << color;
368 else if (strcmp (argv[i],
"-black-and-white") == 0) cout << black_and_white;
370 else if (strcmp (argv[i],
"-transpose-out") == 0) cout << transpose;
371 else if (strcmp (argv[i],
"-notranspose-out") == 0) cout << notranspose;
372 else if (strcmp (argv[i],
"-name") == 0) {
374 cerr <<
"-name: missing argument" << endl;
377 cout << setbasename (argv[i]);
380 else if (strcmp (argv[i],
"-transpose-in") == 0) ;
381 else if (strcmp (argv[i],
"-notranspose-in") == 0) ;
382 else if (strcmp (argv[i],
"-input-hb") == 0) ;
383 else if (strcmp (argv[i],
"-input-mm") == 0) ;
386 cerr <<
"unexpected command-line argument `" << argv[i] <<
"'" << endl;
400 unsigned int n = iorheo::getnrhs(cin);
405 string rhs_type = iorheo::getrhstype(cin);
411 cout <<
hb << setnrhs(
n) << setrhstype(rhs_type) << notranspose <<
a ;
415 for (
unsigned int i = 0; i <
n; i++) {
423 if (rhs_type[1] ==
'G') {
425 for (
unsigned int i = 0; i <
n; i++) {
433 if (rhs_type[2] ==
'X') {
435 for (
unsigned int i = 0; i <
n; i++) {
field::size_type size_type
void print_postscript(std::ostream &s, const csr< T, sequential > &a)
int main(int argc, char **argv)
see the csr page for the full documentation
see the environment page for the full documentation
idiststream: see the diststream page for the full documentation
see the vec page for the full documentation
void mtx(const Expr &a_expr, string a_name)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format matrix_market
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format hb
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format matlab
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format dump
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format ml
This file is part of Rheolef.
t operator()(const t &a, const t &b)