1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #include "mathematicarepresentation.h"
23 using namespace Shapes
;
27 Helpers::mathematicaFormat( size_t n1
, size_t n2
, size_t tda
, const double * data
)
29 std::ostringstream os
;
31 for( const double * row
= data
; row
!= data
+ n1
* tda
; row
+= tda
)
38 for( const double * src
= row
; src
!= row
+ n2
; ++src
)
53 Helpers::mathematicaFormatTransposed( size_t n1
, size_t n2
, size_t tda
, const double * data
)
55 std::ostringstream os
;
57 for( const double * row
= data
; row
!= data
+ n2
; ++row
)
64 for( const double * src
= row
; src
!= row
+ n1
* tda
; src
+= tda
)
79 Helpers::mathematicaFormat( size_t n
, size_t stride
, const double ** begin
, const double ** end
)
81 std::ostringstream os
;
83 for( const double ** row
= begin
; row
!= end
; ++row
)
90 for( const double * src
= *row
; src
!= *row
+ n
* stride
; src
+= stride
)
105 Helpers::mathematicaFormat( size_t n
, size_t stride
, const double * data
)
107 std::ostringstream os
;
109 for( const double * src
= data
; src
!= data
+ n
* stride
; src
+= stride
)
122 Helpers::mathematicaFormat( const gsl_vector
& x
)
124 return Helpers::mathematicaFormat( x
.size
, x
.stride
, x
.data
);
128 Helpers::mathematicaFormat( const gsl_matrix
& x
, bool transpose
)
132 return Helpers::mathematicaFormatTransposed( x
.size1
, x
.size2
, x
.tda
, x
.data
);
136 return Helpers::mathematicaFormat( x
.size1
, x
.size2
, x
.tda
, x
.data
);