1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
/*1:*/
#line 5 "./twod_matrix.cweb"
#include "twod_matrix.h"
#include "tl_exception.h"
/*2:*/
#line 20 "./twod_matrix.cweb"
ConstTwoDMatrix::ConstTwoDMatrix(const TwoDMatrix&m)
:ConstGeneralMatrix(m){}
ConstTwoDMatrix::ConstTwoDMatrix(const TwoDMatrix&m,int first_col,int num)
:ConstGeneralMatrix(m,0,first_col,m.nrows(),num){}
ConstTwoDMatrix::ConstTwoDMatrix(const ConstTwoDMatrix&m,int first_col,int num)
:ConstGeneralMatrix(m,0,first_col,m.nrows(),num){}
ConstTwoDMatrix::ConstTwoDMatrix(int first_row,int num,const TwoDMatrix&m)
:ConstGeneralMatrix(m,first_row,0,num,m.ncols()){}
ConstTwoDMatrix::ConstTwoDMatrix(int first_row,int num,const ConstTwoDMatrix&m)
:ConstGeneralMatrix(m,first_row,0,num,m.ncols()){}
/*:2*/
#line 10 "./twod_matrix.cweb"
;
/*3:*/
#line 37 "./twod_matrix.cweb"
void ConstTwoDMatrix::writeMat4(FILE*fd,const char*vname)const
{
Mat4Header header(*this,vname);
header.write(fd);
for(int j= 0;j<ncols();j++)
for(int i= 0;i<nrows();i++)
fwrite(&(get(i,j)),sizeof(double),1,fd);
}
/*:3*/
#line 11 "./twod_matrix.cweb"
;
/*4:*/
#line 48 "./twod_matrix.cweb"
void TwoDMatrix::copyRow(int from,int to)
{
if(from!=to)
copyRow(ConstTwoDMatrix(*this),from,to);
}
void TwoDMatrix::copyRow(const ConstTwoDMatrix&m,int from,int to)
{
ConstVector fr_row(from,m);
Vector to_row(to,*this);
to_row= fr_row;
}
void TwoDMatrix::addRow(double d,const ConstTwoDMatrix&m,int from,int to)
{
ConstVector fr_row(from,m);
Vector to_row(to,*this);
to_row.add(d,fr_row);
}
/*:4*/
#line 12 "./twod_matrix.cweb"
;
/*5:*/
#line 71 "./twod_matrix.cweb"
void TwoDMatrix::copyColumn(int from,int to)
{
if(from!=to)
copyColumn(ConstTwoDMatrix(*this),from,to);
}
void TwoDMatrix::copyColumn(const ConstTwoDMatrix&m,int from,int to)
{
ConstVector fr_col(m,from);
Vector to_col(*this,to);
to_col= fr_col;
}
void TwoDMatrix::addColumn(double d,const ConstTwoDMatrix&m,int from,int to)
{
ConstVector fr_col(m,from);
Vector to_col(*this,to);
to_col.add(d,fr_col);
}
/*:5*/
#line 13 "./twod_matrix.cweb"
;
/*6:*/
#line 93 "./twod_matrix.cweb"
void TwoDMatrix::save(const char*fname)const
{
FILE*fd;
if(NULL==(fd= fopen(fname,"w"))){
TL_RAISE("Cannot open file for writing in TwoDMatrix::save");
}
for(int row= 0;row<nrows();row++){
for(int col= 0;col<ncols();col++)
fprintf(fd," %20.10g",get(row,col));
fprintf(fd,"\n");
}
fclose(fd);
}
/*:6*/
#line 14 "./twod_matrix.cweb"
;
/*7:*/
#line 109 "./twod_matrix.cweb"
Mat4Header::Mat4Header(const ConstTwoDMatrix&m,const char*vn)
:type(0),rows(m.nrows()),cols(m.ncols()),imagf(0),namelen(strlen(vn)+1),
vname(vn)
{}
/*:7*/
#line 15 "./twod_matrix.cweb"
;
/*8:*/
#line 117 "./twod_matrix.cweb"
Mat4Header::Mat4Header(const ConstTwoDMatrix&m,const char*vn,const char*dummy)
:type(1),rows(m.nrows()),cols(m.ncols()),imagf(0),namelen(strlen(vn)+1),
vname(vn)
{}
/*:8*/
#line 16 "./twod_matrix.cweb"
;
/*9:*/
#line 125 "./twod_matrix.cweb"
void Mat4Header::write(FILE*fd)const
{
fwrite(&type,sizeof(int),1,fd);
fwrite(&rows,sizeof(int),1,fd);
fwrite(&cols,sizeof(int),1,fd);
fwrite(&imagf,sizeof(int),1,fd);
fwrite(&namelen,sizeof(int),1,fd);
fwrite(vname,1,namelen,fd);
}
/*:9*/
#line 17 "./twod_matrix.cweb"
;
/*:1*/
|