UQTk: Uncertainty Quantification Toolkit 3.1.5
arrayio.h
Go to the documentation of this file.
1/* =====================================================================================
2
3 The UQ Toolkit (UQTk) version 3.1.5
4 Copyright (2024) NTESS
5 https://www.sandia.gov/UQToolkit/
6 https://github.com/sandialabs/UQTk
7
8 Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10 retains certain rights in this software.
11
12 This file is part of The UQ Toolkit (UQTk)
13
14 UQTk is open source software: you can redistribute it and/or modify
15 it under the terms of BSD 3-Clause License
16
17 UQTk is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 BSD 3 Clause License for more details.
21
22 You should have received a copy of the BSD 3 Clause License
23 along with UQTk. If not, see https://choosealicense.com/licenses/bsd-3-clause/.
24
25 Questions? Contact the UQTk Developers at https://github.com/sandialabs/UQTk/discussions
26 Sandia National Laboratories, Livermore, CA, USA
27===================================================================================== */
30
31#ifndef ARRAYIO_H
32#define ARRAYIO_H
33
34#include <iostream>
35#include <fstream>
36#include <sstream>
37#include <stdlib.h>
38
39#include "Array1D.h"
40#include "Array2D.h"
41
42
46template <typename T> void read_datafile(Array2D<T> &data, const char *filename);
47
53template <typename T> void read_datafileVS(Array2D<T> &data, const char *filename);
54
55// Read a datafile from filename and store it in an 1d array of 1d arrays
56// array data of typename T
57template <typename T>
58void read_datafileVS(Array1D<Array1D<T> > &data, const char *filename);
59
65template <typename T> void read_datafileVS(std::vector<T> &data, int &nrows, int &ncols, const char *filename);
66
70template <typename T> void read_datafile_1d(Array1D<T>& data, const char* filename);
71
77template <typename T> void read_datafileVS(Array1D<T> &data, const char *filename);
78
81template <typename T>
82void write_datafile(const Array2D<T> &data, const char *filename, const char *action);
83
86template <typename T>
87void write_datafile(const Array2D<T> &data, const char *filename);
88
91template <typename T>
92void write_datafile(const std::vector<T> &data, const int &nrows, const int &ncols, const char *storage, const char *filename, const char *action);
93
97template <typename T>
98void write_datafile_size(const Array2D<T> &data, const char *filename);
99
102template <typename T> void write_datafile_1d(const Array1D<T>& data, const char* filename);
103
104#endif // ARRAYIO_H
1D Array class for any type T
2D Array class for any type T
void read_datafile_1d(Array1D< T > &data, const char *filename)
Read a data from filename in a vector form and store it in a 1d array data of typename T.
Definition arrayio.cpp:355
void read_datafile(Array2D< T > &data, const char *filename)
Read a datafile from filename in a matrix form and store it in the 2d array data of typename T.
Definition arrayio.cpp:38
void write_datafile(const Array2D< T > &data, const char *filename, const char *action)
Write/append the contents of a 2d array data of typename T to file filename in a matrix form.
Definition arrayio.cpp:525
void write_datafile_size(const Array2D< T > &data, const char *filename)
Write to file filename the number of rows and number of columns on the first line,...
Definition arrayio.cpp:448
void write_datafile_1d(const Array1D< T > &data, const char *filename)
Write the contents of a 1d array data of typename T to file filename in a vector form.
Definition arrayio.cpp:653
void read_datafileVS(Array2D< T > &data, const char *filename)
Read a datafile from filename in a matrix form and store it in the 2d array data if typename T.
Definition arrayio.cpp:94
Stores data of any type T in a 1D array.
Definition Array1D.h:61
Stores data of any type T in a 2D array.
Definition Array2D.h:60