STAG C++  2.0.0
Spectral Toolkit of Algorithms for Graphs
Loading...
Searching...
No Matches
data.h File Reference

Description

Methods for dealing with datasets.

This file contains methods for reading and writing data to disk, and for converting data between different formats.

Classes

class  stag::DataPoint
 A data point in d-dimensional space. More...
 

Functions

DenseMat stag::load_matrix (std::string &filename)
 
void stag::save_matrix (DenseMat &data, std::string &filename)
 
std::vector< stag::DataPointstag::matrix_to_datapoints (DenseMat *data)
 

Function Documentation

◆ load_matrix()

DenseMat stag::load_matrix ( std::string &  filename)

Load data into a matrix from a file.

Each line of the file corresponds to a row in the matrix. On each row, matrix entries should be separated by blank spaces, or commas. Every row in the file must contain the same number of entries.

Lines beginning with '#' or '//' are ignored.

Parameters
filenamethe name of the file containing the data
Returns
a DenseMat containing the data from the file
Exceptions
std::runtime_errorif the file doesn't exist or cannot be parsed

◆ save_matrix()

void stag::save_matrix ( DenseMat data,
std::string &  filename 
)

Save a data matrix to a text file.

Parameters
datathe matrix to be saved
filenamethe name of the file to save the data to
Exceptions
std::runtime_errorif the file cannot be opened for writing

◆ matrix_to_datapoints()

std::vector< stag::DataPoint > stag::matrix_to_datapoints ( DenseMat data)

Convert data in an eigen matrix to an array of data point pointers.

Parameters
datathe eigen matrix containing the data
Returns
a vector of stag::DataPoint pointing to the rows of the matrix