Home | Develop | Download | Contact
RaVectorDouble.hpp
1/*
2 * RaVectorDouble.hpp
3 *
4 * Copyright 2018 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 *
21 */
22
30#ifndef __PDS_RAVECTORDOUBLE_HPP__
31#define __PDS_RAVECTORDOUBLE_HPP__
32
33#include <string>
34#include <list>
35#include <vector>
36#include <fstream>
37#include <iomanip>
38#include <Pds/RaDefines>
39
49namespace Pds{
54namespace Ra{
55
56
75 std::vector<double> VectorDoubleRandN(unsigned int N);
76
77
93 std::vector<double> VectorDoubleRandU(unsigned int N,double begin, double end);
94
111 bool VectorDoubleFillRandU(std::vector<double> &b,double begin, double end);
112
126 std::vector<double> VectorDoubleZero(unsigned int N);
127
150 void PrintVectorDouble(std::vector<double> b);
151
152
183 bool ExportVectorDoubleXmlToStream(std::ofstream &myfile,const std::vector<double> &Block);
184
185
204 std::string ExportVectorDoubleXmlToString(const std::vector<double> &Block);
205
206
229 std::vector<double> ImportVectorDoubleXmlFromString(const std::string &str);
230
231
243 template <typename Datum>
244 bool SaveStdVector(const std::vector<Datum> &Vec, const std::string &filename)
245 {
246 if(filename.size()==0) return false;
247 if(Vec.size()==0) return false;
248
249 std::ofstream myfile;
250 myfile.open(filename);
251 if(myfile.is_open())
252 {
253 for(unsigned int n=0;n<Vec.size();n++)
254 myfile<<std::setprecision(Pds::Ra::StringPrecision)<<Vec[n]<<"\n";
255 myfile.close();
256 }
257 else return false;
258
259 return true;
260 }
261
262
267} // namespace Ra
268} // namespace Pds
269
270
275#endif /* __PDS_RATOOLS_HPP__ */
const unsigned int StringPrecision
Número de decimales a mostrar cuando se imprime en pantalla o en archivo.
Definition: RaDefines.hpp:299
bool VectorDoubleFillRandU(std::vector< double > &b, double begin, double end)
Números aleatorios con una distribución uniforme entre begin a end.
std::vector< double > VectorDoubleZero(unsigned int N)
Números zero.
std::vector< double > VectorDoubleRandU(unsigned int N, double begin, double end)
Números aleatorios con una distribución uniforme entre begin a end.
std::vector< double > VectorDoubleRandN(unsigned int N)
Números aleatorios con una distribución normal.
bool SaveStdVector(const std::vector< Datum > &Vec, const std::string &filename)
Salva los datos de un std::vector<Datum> en un archivo de te texto. Un dato por linea.
std::vector< double > ImportVectorDoubleXmlFromString(const std::string &str)
Carga el contenido de una std::vector<double> desde un std::string en formato Xml.
void PrintVectorDouble(std::vector< double > b)
Imprime un vector std::vector<double>.
std::string ExportVectorDoubleXmlToString(const std::vector< double > &Block)
Retorna un std::string en formato Xml con el contenido del VectorDouble.
bool ExportVectorDoubleXmlToStream(std::ofstream &myfile, const std::vector< double > &Block)
Retorna un std::string en formato Xml con el contenido del VectorDouble.
Nombre de espacio para Pds (Procesamiento Digital de Senales)
Definition: AbstractRV.hpp:42

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed