UQTk: Uncertainty Quantification Toolkit 3.1.5
arrayio.h File Reference

Header file for array read/write utilities. More...

#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include "Array1D.h"
#include "Array2D.h"

Go to the source code of this file.

Functions

template<typename T >
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.
 
template<typename T >
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.
 
template<typename T >
void read_datafileVS (Array1D< Array1D< T > > &data, const char *filename)
 
template<typename T >
void read_datafileVS (std::vector< T > &data, int &nrows, int &ncols, const char *filename)
 Read a datafile from filename in a matrix form and store it in a std::vector in column-major storage scheme.
 
template<typename 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.
 
template<typename T >
void read_datafileVS (Array1D< T > &data, const char *filename)
 Read a datafile from filename in a vector form and store it in the 1d array data of typename T.
 
template<typename T >
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.
 
template<typename T >
void write_datafile (const Array2D< T > &data, const char *filename)
 Write the contents of a 2d array data of typename T to file filename in a matrix form.
 
template<typename T >
void write_datafile (const std::vector< T > &data, const int &nrows, const int &ncols, const char *storage, const char *filename, const char *action)
 Write the contents of a vector of typename T to file filename in a matrix form.
 
template<typename T >
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, followed by the contents of a 2d array data of typename T in a matrix form.
 
template<typename T >
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.
 

Detailed Description

Header file for array read/write utilities.

Function Documentation

◆ read_datafile()

template<typename T >
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.

Note
The array data needs to have the correct sizes

◆ read_datafile_1d()

template<typename 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.

Note
The array data needs to have the correct size

◆ read_datafileVS() [1/4]

template<typename T >
void read_datafileVS ( Array1D< Array1D< T > > & data,
const char * filename )

◆ read_datafileVS() [2/4]

template<typename T >
void read_datafileVS ( Array1D< T > & data,
const char * filename )

Read a datafile from filename in a vector form and store it in the 1d array data of typename T.

Note
The array data is resized to match the file contents
This function makes two passes: the first pass figures the no. or rows and columns, then the data array is appropriately resized, and the filename is read during second pass

◆ read_datafileVS() [3/4]

template<typename T >
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.

Note
The array data is resized to match the file contents
This function makes two passes: the first pass figures the no. or rows and columns, then the data array is appropriately resized, and the filename is read during second pass

◆ read_datafileVS() [4/4]

template<typename T >
void read_datafileVS ( std::vector< T > & data,
int & nrows,
int & ncols,
const char * filename )

Read a datafile from filename in a matrix form and store it in a std::vector in column-major storage scheme.

Note
The vector is resized to match the file contents
This function makes two passes: the first pass figures the no. or rows and columns, then the data vector is appropriately resized, and the filename is read during second pass

◆ write_datafile() [1/3]

template<typename T >
void write_datafile ( const Array2D< T > & data,
const char * filename )

Write the contents of a 2d array data of typename T to file filename in a matrix form.

◆ write_datafile() [2/3]

template<typename T >
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.

◆ write_datafile() [3/3]

template<typename T >
void write_datafile ( const std::vector< T > & data,
const int & nrows,
const int & ncols,
const char * storage,
const char * filename,
const char * action )

Write the contents of a vector of typename T to file filename in a matrix form.

◆ write_datafile_1d()

template<typename T >
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.

◆ write_datafile_size()

template<typename T >
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, followed by the contents of a 2d array data of typename T in a matrix form.