parent
71109fa551
commit
5a6cd4b0f2
18 changed files with 333 additions and 115 deletions
|
|
@ -112,7 +112,12 @@ namespace rotgen
|
|||
|
||||
friend std::ostream& operator<<(std::ostream& os, ref const& r)
|
||||
{
|
||||
return os << r.base() << "\n";
|
||||
return os << r.base();
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, format<ref> const& r)
|
||||
{
|
||||
return os << format{r.matrix_.base(),r.format_};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -201,7 +206,12 @@ namespace rotgen
|
|||
|
||||
friend std::ostream& operator<<(std::ostream& os, ref const& r)
|
||||
{
|
||||
return os << r.base() << "\n";
|
||||
return os << r.base();
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, format<ref> const& r)
|
||||
{
|
||||
return os << format{r.matrix_.base(),r.format_};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ namespace rotgen
|
|||
inline constexpr int Aligned64 = 64;
|
||||
inline constexpr int Aligned128 = 128;
|
||||
inline constexpr int Aligned = default_alignment;
|
||||
|
||||
inline constexpr int DontAlignCols = 1;
|
||||
inline constexpr int StreamPrecision = -1;
|
||||
inline constexpr int FullPrecision = -2;
|
||||
}
|
||||
|
||||
namespace rotgen::detail
|
||||
|
|
|
|||
51
include/rotgen/dynamic/format.hpp
Normal file
51
include/rotgen/dynamic/format.hpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
#include <rotgen/config.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
class ROTGEN_EXPORT ioformat
|
||||
{
|
||||
private:
|
||||
struct payload;
|
||||
std::unique_ptr<payload> storage_;
|
||||
|
||||
public:
|
||||
ioformat( int precision, int flags = 0
|
||||
, std::string const& coeffSeparator = " "
|
||||
, std::string const& rowSeparator = "\n"
|
||||
, std::string const& rowPrefix = "", std::string const& rowSuffix = ""
|
||||
, std::string const& matPrefix = "", std::string const& matSuffix = ""
|
||||
, char fill = ' '
|
||||
);
|
||||
|
||||
|
||||
~ioformat();
|
||||
|
||||
std::unique_ptr<payload> const& storage() const { return storage_; }
|
||||
};
|
||||
|
||||
template <typename M>
|
||||
struct format
|
||||
{
|
||||
format(const M& m, const ioformat& f) : matrix_(m), format_(f) {}
|
||||
|
||||
M const& matrix_;
|
||||
ioformat const& format_;
|
||||
};
|
||||
|
||||
template <typename M>
|
||||
std::ostream& operator<<(std::ostream& os, const format<M>& f)
|
||||
{
|
||||
return os << format{f.matrix_.base(), f.format_};
|
||||
}
|
||||
}
|
||||
34
include/rotgen/fixed/format.hpp
Normal file
34
include/rotgen/fixed/format.hpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
#include <rotgen/config.hpp>
|
||||
#include <rotgen/concepts.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
using ioformat = Eigen::IOFormat;
|
||||
|
||||
template <typename M>
|
||||
struct format
|
||||
{
|
||||
format(const M& m, const ioformat& f) : matrix_(m), format_(f) {}
|
||||
|
||||
M const& matrix_;
|
||||
ioformat const& format_;
|
||||
};
|
||||
|
||||
template <typename M>
|
||||
std::ostream& operator<<(std::ostream& os, const format<M>& f)
|
||||
{
|
||||
if constexpr(concepts::eigen_compatible<M>) return os << f.matrix_.format(f.format_);
|
||||
else return os << f.matrix_.base().format(f.format_);
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +96,7 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
SOURCENAME div(TYPE s) const;
|
||||
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
|
||||
SOURCENAME inverse() const;
|
||||
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, format<CLASSNAME> const&);
|
||||
const TYPE* data() const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <rotgen/detail/generators.hpp>
|
||||
#include <rotgen/dynamic/format.hpp>
|
||||
#include <rotgen/config.hpp>
|
||||
#include <initializer_list>
|
||||
#include <cstddef>
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
CLASSNAME& operator/=(TYPE d);
|
||||
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <rotgen/impl/matrix.hpp>
|
||||
#include <rotgen/impl/map.hpp>
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
|
|
@ -181,4 +182,19 @@ namespace rotgen
|
|||
payload (double* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (double* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
};
|
||||
|
||||
//
|
||||
struct ioformat::payload
|
||||
{
|
||||
Eigen::IOFormat instance;
|
||||
|
||||
payload ( int p, int f
|
||||
, std::string const& cs, std::string const& rsp
|
||||
, std::string const& rp, std::string const& rs
|
||||
, std::string const& mp, std::string const& ms
|
||||
, char fill
|
||||
)
|
||||
: instance(p,f,cs,rsp,rp,rs,mp,ms,fill)
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@
|
|||
#include <rotgen/dynamic/block.hpp>
|
||||
#include <rotgen/dynamic/map.hpp>
|
||||
#include <rotgen/dynamic/svd.hpp>
|
||||
#include <rotgen/dynamic/format.hpp>
|
||||
#else
|
||||
#include <rotgen/fixed/matrix.hpp>
|
||||
#include <rotgen/fixed/block.hpp>
|
||||
#include <rotgen/fixed/map.hpp>
|
||||
#include <rotgen/fixed/svd.hpp>
|
||||
#include <rotgen/fixed/format.hpp>
|
||||
#endif
|
||||
|
||||
#include <rotgen/common/ref.hpp>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue