Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Functions
Input/Output

Provides load and store operations for sparse matrices. More...

Functions

template<typename Printable >
void cusp::print (const Printable &p)
 print a textual representation of an object More...
 
template<typename Printable , typename Stream >
void cusp::print (const Printable &p, Stream &s)
 Print a textual representation of an object on a given stream. More...
 
template<typename Matrix >
void cusp::io::read_binary_file (Matrix &mtx, const std::string &filename)
 Read a binary file. More...
 
template<typename Matrix , typename Stream >
void cusp::io::read_binary_stream (Matrix &mtx, Stream &input)
 Read binary data from a stream. More...
 
template<typename Matrix >
void cusp::io::write_binary_file (const Matrix &mtx, const std::string &filename)
 Write a binary file. More...
 
template<typename Matrix , typename Stream >
void cusp::io::write_binary_stream (const Matrix &mtx, Stream &output)
 Write binary data to a stream. More...
 
template<typename Matrix >
thrust::tuple< typename
Matrix::index_type, typename
Matrix::index_type > 
cusp::io::read_dimacs_file (Matrix &mtx, const std::string &filename)
 Read a Dimacs file. More...
 
template<typename Matrix , typename Stream >
thrust::tuple< typename
Matrix::index_type, typename
Matrix::index_type > 
cusp::io::read_dimacs_stream (Matrix &mtx, Stream &input)
 Read Dimacs data from a stream. More...
 
template<typename Matrix >
void cusp::io::write_dimacs_file (const Matrix &mtx, const thrust::tuple< typename Matrix::index_type, typename Matrix::index_type > &t, const std::string &filename)
 Write a Dimacs file. More...
 
template<typename Matrix , typename Stream >
void cusp::io::write_dimacs_stream (const Matrix &mtx, const thrust::tuple< typename Matrix::index_type, typename Matrix::index_type > &t, Stream &output)
 Write Dimacs data to a stream. More...
 
template<typename Matrix >
void cusp::io::read_matrix_market_file (Matrix &mtx, const std::string &filename)
 Read a MatrixMarket file. More...
 
template<typename Matrix , typename Stream >
void cusp::io::read_matrix_market_stream (Matrix &mtx, Stream &input)
 Read MatrixMarket data from a stream. More...
 
template<typename Matrix >
void cusp::io::write_matrix_market_file (const Matrix &mtx, const std::string &filename)
 Write a MatrixMarket file. More...
 
template<typename Matrix , typename Stream >
void cusp::io::write_matrix_market_stream (const Matrix &mtx, Stream &output)
 Write MatrixMarket data to a stream. More...
 

Function Documentation

template<typename Printable >
void cusp::print ( const Printable &  p)

print a textual representation of an object

Template Parameters
Printableprintable type
Parameters
pmatrix, array, or other printable object
Example
The following code snippet demonstrates how to use print.
#include <cusp/array2d.h>
#include <cusp/print.h>
int main(void)
{
// initialize a 2x3 matrix
A(0,0) = 10; A(0,1) = 20; A(0,2) = 30;
A(1,0) = 40; A(1,1) = 50; A(1,2) = 60;
// print A
return 0;
}
Examples:
array1d.cu, array2d_raw.cu, blas.cu, coo.cu, csr.cu, csr_raw.cu, csr_view.cu, dia.cu, diffusion.cu, ell.cu, hyb.cu, matrix_market.cu, multiply.cu, poisson.cu, transpose.cu, and unordered_triplets.cu.
template<typename Printable , typename Stream >
void cusp::print ( const Printable &  p,
Stream &  s 
)

Print a textual representation of an object on a given stream.

Template Parameters
Printableprintable type
Streamoutput stream type
Parameters
pmatrix, array, or other printable object
sstream on which to write the output
Example
The following code snippet demonstrates how to use print.
#include <cusp/array2d.h>
#include <cusp/print.h>
#include <sstream>
int main(void)
{
// initialize a 2x3 matrix
A(0,0) = 10; A(0,1) = 20; A(0,2) = 30;
A(1,0) = 40; A(1,1) = 50; A(1,2) = 60;
std::ostringstream oss;
// print A to stream
cusp::print(A, oss);
return 0;
}
template<typename Matrix >
void cusp::io::read_binary_file ( Matrix &  mtx,
const std::string &  filename 
)

Read a binary file.

Template Parameters
Matrixmatrix container
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
filenamefile name of the binary file
Overview
Note
any contents of mtx will be overwritten
Example
#include <cusp/io/binary.h>
int main(void)
{
// read matrix stored in A.mtx into a coo_matrix
return 0;
}
See Also
write_binary_file
write_binary_stream
template<typename Matrix , typename Stream >
void cusp::io::read_binary_stream ( Matrix &  mtx,
Stream &  input 
)

Read binary data from a stream.

Template Parameters
Matrixmatrix container
Streamstream type
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
inputstream from which to read the binary contents
Overview
Note
any contents of mtx will be overwritten
Example
#include <cusp/io/binary.h>
int main(void)
{
// read matrix stored in A.mtx into a coo_matrix
return 0;
}
See Also
write_binary_file
write_binary_stream
template<typename Matrix >
thrust::tuple<typename Matrix::index_type, typename Matrix::index_type> cusp::io::read_dimacs_file ( Matrix &  mtx,
const std::string &  filename 
)

Read a Dimacs file.

Template Parameters
Matrixmatrix container
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
filenamefile name of the Dimacs file
Overview
Note
any contents of mtx will be overwritten
Example
#include <cusp/io/dimacs.h>
int main(void)
{
// read matrix stored in A.mtx into a coo_matrix
thrust::tuple<int,int> nodes;
nodes = cusp::io::read_dimacs_file(A, "A.dimacs");
return 0;
}
See Also
write_dimacs_file
write_dimacs_stream
template<typename Matrix , typename Stream >
thrust::tuple<typename Matrix::index_type, typename Matrix::index_type> cusp::io::read_dimacs_stream ( Matrix &  mtx,
Stream &  input 
)

Read Dimacs data from a stream.

Template Parameters
Matrixmatrix container
Streamstream type
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
inputstream from which to read the Dimacs contents
Overview
Note
any contents of mtx will be overwritten
Example
#include <cusp/io/dimacs.h>
int main(void)
{
// read matrix stored in A.mtx into a coo_matrix
thrust::tuple<int,int> nodes;
nodes = cusp::io::read_dimacs_stream(A, std::cin);
return 0;
}
See Also
write_dimacs_file
write_dimacs_stream
template<typename Matrix >
void cusp::io::read_matrix_market_file ( Matrix &  mtx,
const std::string &  filename 
)

Read a MatrixMarket file.

Template Parameters
Matrixmatrix container
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
filenamefile name of the MatrixMarket file
Overview
Note
any contents of mtx will be overwritten
Example
int main(void)
{
// read matrix stored in A.mtx into a coo_matrix
return 0;
}
See Also
write_matrix_market_file
write_matrix_market_stream
Examples:
diagonal.cu, and matrix_market.cu.
template<typename Matrix , typename Stream >
void cusp::io::read_matrix_market_stream ( Matrix &  mtx,
Stream &  input 
)

Read MatrixMarket data from a stream.

Template Parameters
Matrixmatrix container
Streamstream type
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
inputstream from which to read the MatrixMarket contents
Overview
Note
any contents of mtx will be overwritten
Example
int main(void)
{
// read matrix stored in A.mtx into a coo_matrix
return 0;
}
See Also
write_matrix_market_file
write_matrix_market_stream
template<typename Matrix >
void cusp::io::write_binary_file ( const Matrix &  mtx,
const std::string &  filename 
)

Write a binary file.

Template Parameters
Matrixmatrix container
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
filenamefile name of the binary file
Overview
Note
if the file already exists it will be overwritten
Example
#include <cusp/array2d.h>
#include <cusp/io/binary.h>
int main(void)
{
// create a simple example
A(0,0) = 10; A(0,1) = 0; A(0,2) = 20; A(0,3) = 0;
A(1,0) = 0; A(1,1) = 30; A(1,2) = 0; A(1,3) = 40;
A(2,0) = 50; A(2,1) = 60; A(2,2) = 70; A(2,3) = 80;
// save A into binary file
return 0;
}
See Also
read_binary_file
read_binary_stream
template<typename Matrix , typename Stream >
void cusp::io::write_binary_stream ( const Matrix &  mtx,
Stream &  output 
)

Write binary data to a stream.

Template Parameters
Matrixmatrix container
Streamstream type
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
outputstream to which the binary contents will be written
Example
#include <cusp/array2d.h>
#include <cusp/io/binary.h>
int main(void)
{
// create a simple example
A(0,0) = 10; A(0,1) = 0; A(0,2) = 20; A(0,3) = 0;
A(1,0) = 0; A(1,1) = 30; A(1,2) = 0; A(1,3) = 40;
A(2,0) = 50; A(2,1) = 60; A(2,2) = 70; A(2,3) = 80;
// save A into binary file
return 0;
}
See Also
read_binary_file
read_binary_stream
template<typename Matrix >
void cusp::io::write_dimacs_file ( const Matrix &  mtx,
const thrust::tuple< typename Matrix::index_type, typename Matrix::index_type > &  t,
const std::string &  filename 
)

Write a Dimacs file.

Template Parameters
Matrixmatrix container
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
ta tuple of indices specifying the source and sink vertices
filenamefile name of the Dimacs file
Overview
Note
if the file already exists it will be overwritten
Example
#include <cusp/io/dimacs.h>
#include <cusp/array2d.h>
int main(void)
{
// create a simple example
A(0,0) = 10; A(0,1) = 0; A(0,2) = 20; A(0,3) = 0;
A(1,0) = 0; A(1,1) = 30; A(1,2) = 0; A(1,3) = 40;
A(2,0) = 50; A(2,1) = 60; A(2,2) = 70; A(2,3) = 80;
A(3,0) = 0; A(3,1) = 0; A(3,2) = 0; A(3,3) = 0;
// save A into Dimacs file
thrust::tuple<int,int> nodes(0,3);
cusp::io::write_dimacs_file(A, nodes, "A.dimacs");
return 0;
}
See Also
read_dimacs_file
read_dimacs_stream
template<typename Matrix , typename Stream >
void cusp::io::write_dimacs_stream ( const Matrix &  mtx,
const thrust::tuple< typename Matrix::index_type, typename Matrix::index_type > &  t,
Stream &  output 
)

Write Dimacs data to a stream.

Template Parameters
Matrixmatrix container
Streamstream type
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
ta tuple of indices specifying the source and sink vertices
outputstream to which the Dimacs contents will be written
Example
#include <cusp/io/dimacs.h>
#include <cusp/array2d.h>
int main(void)
{
// create a simple example
A(0,0) = 10; A(0,1) = 0; A(0,2) = 20; A(0,3) = 0;
A(1,0) = 0; A(1,1) = 30; A(1,2) = 0; A(1,3) = 40;
A(2,0) = 50; A(2,1) = 60; A(2,2) = 70; A(2,3) = 80;
A(3,0) = 0; A(3,1) = 0; A(3,2) = 0; A(3,3) = 0;
// save A into Dimacs file
thrust::tuple<int,int> nodes(0,3);
cusp::io::write_dimacs_stream(A, nodes, std::cout);
return 0;
}
See Also
read_dimacs_file
read_dimacs_stream
template<typename Matrix >
void cusp::io::write_matrix_market_file ( const Matrix &  mtx,
const std::string &  filename 
)

Write a MatrixMarket file.

Template Parameters
Matrixmatrix container
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
filenamefile name of the MatrixMarket file
Overview
Note
if the file already exists it will be overwritten
Example
#include <cusp/array2d.h>
int main(void)
{
// create a simple example
A(0,0) = 10; A(0,1) = 0; A(0,2) = 20; A(0,3) = 0;
A(1,0) = 0; A(1,1) = 30; A(1,2) = 0; A(1,3) = 40;
A(2,0) = 50; A(2,1) = 60; A(2,2) = 70; A(2,3) = 80;
// save A into MatrixMarket file
return 0;
}
See Also
read_matrix_market_file
read_matrix_market_stream
Examples:
matrix_market.cu.
template<typename Matrix , typename Stream >
void cusp::io::write_matrix_market_stream ( const Matrix &  mtx,
Stream &  output 
)

Write MatrixMarket data to a stream.

Template Parameters
Matrixmatrix container
Streamstream type
Parameters
mtxa matrix container (e.g. csr_matrix or coo_matrix)
outputstream to which the MatrixMarket contents will be written
Example
#include <cusp/array2d.h>
int main(void)
{
// create a simple example
A(0,0) = 10; A(0,1) = 0; A(0,2) = 20; A(0,3) = 0;
A(1,0) = 0; A(1,1) = 30; A(1,2) = 0; A(1,3) = 40;
A(2,0) = 50; A(2,1) = 60; A(2,2) = 70; A(2,3) = 80;
// save A into MatrixMarket file
return 0;
}
See Also
read_matrix_market_file
read_matrix_market_stream