Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102269413
array.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 18, 23:06
Size
3 KB
Mime Type
text/x-c
Expires
Thu, Feb 20, 23:06 (2 d)
Engine
blob
Format
Raw Data
Handle
24303304
Attached To
rLIBMULTISCALE LibMultiScale
array.cc
View Options
/**
* @file array.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Fri Jul 11 15:47:44 2014
*
* @brief This is a wrapper to a vector type to be used when algebra is needed
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "lm_common.hh"
#include "array.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <iomanip>
#include <cstring>
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
Array
::
Array
(
UInt
t
){
vector
.
resize
(
t
);
}
/* -------------------------------------------------------------------------- */
Array
::
Array
(){
}
/* -------------------------------------------------------------------------- */
Array
::~
Array
(){
}
/* -------------------------------------------------------------------------- */
void
Array
::
add
(
UInt
i
,
Real
val
){
vector
[
i
]
+=
val
;
}
/* -------------------------------------------------------------------------- */
void
Array
::
close
(){
}
/* -------------------------------------------------------------------------- */
void
Array
::
printToFile
(
char
*
f
,
UInt
step
){
std
::
ofstream
file
(
f
);
printToFile
(
file
,
step
);
}
/* -------------------------------------------------------------------------- */
UInt
Array
::
printToFile
(
std
::
ofstream
&
f
,
UInt
step
){
for
(
UInt
i
=
0
;
i
<
vector
.
size
();
++
i
)
{
f
<<
i
<<
"
\t
"
<<
step
<<
"
\t
"
<<
std
::
setprecision
(
15
)
<<
std
::
scientific
<<
vector
[
i
]
<<
std
::
endl
;
}
return
0
;
}
/* -------------------------------------------------------------------------- */
Real
*
Array
::
getArray
(){
return
&
vector
[
0
];
}
/* -------------------------------------------------------------------------- */
UInt
Array
::
zero
(){
vector
.
assign
(
vector
.
size
(),
0
);
// mise a zero
return
0
;
}
/* -------------------------------------------------------------------------- */
extern
"C"
{
::
libmultiscale
::
UInt
scaleArray
(
::
libmultiscale
::
Real
*
vector
,
::
libmultiscale
::
UInt
taille
,
::
libmultiscale
::
Real
alpha
);
}
/* -------------------------------------------------------------------------- */
void
Array
::
scale
(
Real
a
){
scaleArray
(
&
vector
[
0
],
vector
.
size
(),
a
);
}
/* -------------------------------------------------------------------------- */
UInt
Array
::
size
(){
return
vector
.
size
();
}
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment