Skip to content

Commit

Permalink
Format with clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
MFTabriz committed Feb 20, 2020
1 parent 40aeb62 commit a8d3fac
Show file tree
Hide file tree
Showing 22 changed files with 3,459 additions and 2,993 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
BasedOnStyle: LLVM

...
8 changes: 7 additions & 1 deletion readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
:alt: Version 0.8.4
.. |Update| image:: https://img.shields.io/badge/Last%20update-15.07.2019-informational.svg
:alt: Last update 15 July 2019
.. |Style| image:: https://img.shields.io/badge/coding%20style-LLVM-black
:alt: Coding style
:target: https://llvm.org/docs/CodingStandards.html
.. |Travis| image:: https://travis-ci.org/MFTabriz/slabcc.svg?branch=master
:alt: Build Status
:target: https://travis-ci.org/MFTabriz/slabcc
Expand All @@ -11,8 +14,11 @@
.. |Zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1419758.svg
:alt: Test Set
:target: https://doi.org/10.5281/zenodo.1419758
.. |License| image:: https://img.shields.io/badge/License-BSD--2--Clause-blue
:alt: License: BSD-2-Clause
:target: https://opensource.org/licenses/BSD-2-Clause

|Version| |Update| |Travis| |Codacy| |Zenodo|
|Version| |Update| |Style| |Travis| |Codacy| |Zenodo| |License|

.. sectnum::

Expand Down
96 changes: 44 additions & 52 deletions src/arma_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,63 @@
#include <iomanip>
#include <iostream>

using namespace std;
using namespace arma;


//single-line output for vec
template<typename T>
ostream &operator << (ostream &o, const Row<T> &vec) {
for (uword elem = 0; elem < vec.n_elem; ++elem) {
o << vec(elem);
if (elem != vec.n_elem - 1) {
o << " ";
}
}
return o;
// single-line output for vec
template <typename T>
std::ostream &operator<<(std::ostream &o, const arma::Row<T> &vec) {
for (arma::uword elem = 0; elem < vec.n_elem; ++elem) {
o << vec(elem);
if (elem != vec.n_elem - 1) {
o << " ";
}
}
return o;
}

template<typename T>
ostream &operator << (ostream &o, const subview<T> &vec) {
for (uword elem = 0; elem < vec.n_elem; ++elem) {
o << vec(elem);
if (elem != vec.n_elem - 1) {
o << " ";
}
}

return o;
}
template <typename T>
std::ostream &operator<<(std::ostream &o, const arma::subview<T> &vec) {
for (arma::uword elem = 0; elem < vec.n_elem; ++elem) {
o << vec(elem);
if (elem != vec.n_elem - 1) {
o << " ";
}
}

//single-line output for mat
template<typename T>
ostream &operator << (ostream &o, const Mat<T> &mat) {
mat.each_row([&o](const Row<T> &row) { o << row << "; "; });
return o;
return o;
}

template<typename T>
istream &operator >> (istream &o, Row<T> &vec) {
vec.for_each([&o](T &elem) { o >> elem; });
return o;
// single-line output for mat
template <typename T>
std::ostream &operator<<(std::ostream &o, const arma::Mat<T> &mat) {
mat.each_row([&o](const arma::Row<T> &row) { o << row << "; "; });
return o;
}

template<typename T>
istream &operator >> (istream &o, subview_row<T> vec) {
vec.for_each([&o](T &elem) { o >> elem; });
return o;
template <typename T>
std::istream &operator>>(std::istream &o, arma::Row<T> &vec) {
vec.for_each([&o](T &elem) { o >> elem; });
return o;
}

template<typename T>
istream &operator >> (istream &o, Cube<T> &c) {
c.for_each([&o](T &elem) { o >> elem; });
return o;
template <typename T>
std::istream &operator>>(std::istream &o, arma::subview_row<T> vec) {
vec.for_each([&o](T &elem) { o >> elem; });
return o;
}

template<typename T>
istream &operator >> (istream &o, Mat<T> &m) {
m.for_each([&o](T &elem) { o >> elem; });
return o;
template <typename T>
std::istream &operator>>(std::istream &o, arma::Cube<T> &c) {
c.for_each([&o](T &elem) { o >> elem; });
return o;
}

template <typename T>
string to_string(T input) {
ostringstream output;
output << setprecision(15);
output << input;
return output.str();
std::istream &operator>>(std::istream &o, arma::Mat<T> &m) {
m.for_each([&o](T &elem) { o >> elem; });
return o;
}


template <typename T> std::string to_string(T input) {
std::ostringstream output;
output << std::setprecision(15) << input;
return output.str();
}
Loading

0 comments on commit a8d3fac

Please sign in to comment.