# Contents of /trunk/paso/src/SparseMatrix_saveHB.cpp

Revision 4829 - (show annotations)
Thu Apr 3 04:02:53 2014 UTC (5 years, 5 months ago) by caltinay
File size: 6832 byte(s)
```checkpointing some SparseMatrix cleanup.

```
 1 2 /***************************************************************************** 3 * 4 * Copyright (c) 2003-2014 by University of Queensland 5 6 * 7 * Primary Business: Queensland, Australia 8 * Licensed under the Open Software License version 3.0 9 10 * 11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC) 12 * Development 2012-2013 by School of Earth Sciences 13 * Development from 2014 by Centre for Geoscience Computing (GeoComp) 14 * 15 *****************************************************************************/ 16 17 18 /****************************************************************************/ 19 20 /* Paso: SparseMatrix saving to Harwell-Boeing format */ 21 22 /****************************************************************************/ 23 24 /* Copyright: ACcESS Australia 2005 */ 25 /* Author: imran@esscc.uq.edu.au */ 26 27 /****************************************************************************/ 28 29 #include "Paso.h" 30 #include "SparseMatrix.h" 31 32 namespace paso { 33 34 /* TODO: Refactor the stuff in here into hbio, just like mmio! */ 35 36 static dim_t M, N, nz; 37 38 static int calc_digits(int); 39 static void fmt_str(int, int, int*, int*, int*, char*, char*); 40 static void print_data(FILE*, int, int, int, char*, const void*, int, int); 41 static void generate_HB(FILE*, dim_t*, dim_t*, const double*); 42 43 /* function to get number of digits in an integer */ 44 int calc_digits(int var) 45 { 46 int digits = 1; 47 while( (var/=10) ) 48 digits++; 49 50 return digits; 51 } 52 53 /* function to generate the format string. 54 * 55 * use maxlen to determine no. of entries per line 56 * use nvalues to determine no. of lines 57 */ 58 void fmt_str(int nvalues, int integer, int *width, int *nlines, int *nperline, char *pfmt, char *fmt) 59 { 60 int per_line; 61 int maxlen = *width; 62 63 if( integer && maxlen < 10 ) 64 maxlen = 10; 65 else 66 maxlen = 13; 67 68 per_line = 80 / maxlen; 69 *nlines = nvalues / per_line; 70 if( nvalues % per_line ) 71 (*nlines)++; 72 73 *nperline = per_line; 74 if (integer) { 75 sprintf( pfmt, "(%dI%d)", per_line, maxlen ); 76 sprintf( fmt, "%%%dd", maxlen ); 77 } else { 78 sprintf( pfmt, "(1P%dE%d.6)", per_line, maxlen ); 79 sprintf( fmt, "%%%d.6E", maxlen ); 80 } 81 *width = maxlen; 82 } 83 84 /* function to print the actual data in the right format */ 85 void print_data(FILE *fp, int n_perline, int width, int nval, char *fmt, 86 const void *ptr, int integer, int adjust) 87 { 88 int entries_done = 0; 89 int padding, i; 90 char pad_fmt[10]; 91 92 padding = 80 - n_perline*width; 93 sprintf(pad_fmt, "%%%dc", padding); 94 95 if (adjust != 1) 96 adjust = 0; 97 98 if (integer) { 99 const dim_t *data = reinterpret_cast(ptr); 100 for(i=0; i(ptr); 112 for (i=0; iptr, pattern->index, val); 185 } else { 186 M = numRows*row_block_size; 187 N = numCols*col_block_size; 188 189 row_ind = new dim_t[len]; 190 col_ind = new dim_t[len]; 191 192 i = 0; 193 for (iCol=0; iColnumOutput; iCol++) 194 for (ic=0; icptr[iCol]-index_offset; iPtrptr[iCol+1]-index_offset; iPtr++) 196 for (ir=0; irindex[iPtr]-index_offset)*row_block_size+ir+1; 198 col_ind[i] = iCol*col_block_size+ic+1; 199 i++; 200 } 201 /* get the col_ptr */ 202 col_ptr = new dim_t[(N+1)]; 203 204 curr_col = 0; 205 for (j=0; (j

## Properties

Name Value
svn:mergeinfo /branches/amg_from_3530/paso/src/SparseMatrix_saveHB.cpp:3531-3826 /branches/lapack2681/paso/src/SparseMatrix_saveHB.cpp:2682-2741 /branches/pasowrap/paso/src/SparseMatrix_saveHB.cpp:3661-3674 /branches/py3_attempt2/paso/src/SparseMatrix_saveHB.cpp:3871-3891 /branches/restext/paso/src/SparseMatrix_saveHB.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/SparseMatrix_saveHB.cpp:3669-3791 /branches/stage3.0/paso/src/SparseMatrix_saveHB.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/SparseMatrix_saveHB.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/SparseMatrix_saveHB.cpp:3517-3974 /release/3.0/paso/src/SparseMatrix_saveHB.cpp:2591-2601 /trunk/paso/src/SparseMatrix_saveHB.cpp:4257-4344 /trunk/ripley/test/python/paso/src/SparseMatrix_saveHB.cpp:3480-3515

 ViewVC Help Powered by ViewVC 1.1.26