Col_meat.hpp   Col_meat.hpp 
skipping to change at line 751 skipping to change at line 751
// min() is used in case in_n_cols is zero // min() is used in case in_n_cols is zero
Mat<eT>::ones( in_n_rows, (std::min)( u32(1), in_n_cols ) ); Mat<eT>::ones( in_n_rows, (std::min)( u32(1), in_n_cols ) );
arma_debug_check( (in_n_cols > 1), "Col::ones(): incompatible dimensions" ); arma_debug_check( (in_n_cols > 1), "Col::ones(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::load(const std::string name, const file_type type) Col<eT>::load(const std::string name, const file_type type, const bool prin t_status)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(name,type); Mat<eT>::load(name, type, print_status);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Col<eT>::load(std::istream& is, const file_type type) Col<eT>::load(std::istream& is, const file_type type, const bool print_stat us)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(is, type); Mat<eT>::load(is, type, print_status);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Col<eT>::quiet_load(const std::string name, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(name, type);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Col<eT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(is, type);
arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_cols > 1), "Col(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
typename Col<eT>::row_iterator typename Col<eT>::row_iterator
Col<eT>::begin_row(const u32 row_num) Col<eT>::begin_row(const u32 row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 4 change blocks. 
4 lines changed or deleted 30 lines changed or added


 Col_proto.hpp   Col_proto.hpp 
skipping to change at line 111 skipping to change at line 111
inline void copy_size(const Mat<eT2>& m); inline void copy_size(const Mat<eT2>& m);
inline void zeros(); inline void zeros();
inline void zeros(const u32 n_elem); inline void zeros(const u32 n_elem);
inline void zeros(const u32 n_rows, const u32 n_cols); inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones(); inline void ones();
inline void ones(const u32 n_elem); inline void ones(const u32 n_elem);
inline void ones(const u32 n_rows, const u32 n_cols); inline void ones(const u32 n_rows, const u32 n_cols);
inline void load(const std::string name, const file_type type = auto_de inline void load(const std::string name, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de inline void load( std::istream& is, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void quiet_load(const std::string name, const file_type type = a
uto_detect);
inline void quiet_load( std::istream& is, const file_type type = a
uto_detect);
typedef eT* row_iterator; typedef eT* row_iterator;
typedef const eT* const_row_iterator; typedef const eT* const_row_iterator;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const u32 row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const u32 row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const u32 row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const u32 row_num) const;
}; };
 End of changes. 1 change blocks. 
4 lines changed or deleted 9 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 1553 skipping to change at line 1553
Cube<eT>::reset() Cube<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0,0); init(0,0,0);
} }
//! save the cube to a file //! save the cube to a file
template<typename eT> template<typename eT>
inline inline
void bool
Cube<eT>::save(const std::string name, const file_type type) const Cube<eT>::save(const std::string name, const file_type type, const bool pri
nt_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool save_okay;
switch(type) switch(type)
{ {
case raw_ascii: case raw_ascii:
diskio::save_raw_ascii(*this, name); save_okay = diskio::save_raw_ascii(*this, name);
break; break;
case arma_ascii: case arma_ascii:
diskio::save_arma_ascii(*this, name); save_okay = diskio::save_arma_ascii(*this, name);
break; break;
case arma_binary: case arma_binary:
diskio::save_arma_binary(*this, name); save_okay = diskio::save_arma_binary(*this, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(*this, name); save_okay = diskio::save_ppm_binary(*this, name);
break; break;
default: default:
arma_stop("Cube::save(): unsupported file type"); arma_warn(print_status, "Cube::save(): unsupported file type");
save_okay = false;
} }
arma_warn( (print_status && (save_okay == false)), "Cube::save(): couldn'
t write to ", name);
return save_okay;
} }
//! save the cube to a stream //! save the cube to a stream
template<typename eT> template<typename eT>
inline inline
void bool
Cube<eT>::save(std::ostream& os, const file_type type) const Cube<eT>::save(std::ostream& os, const file_type type, const bool print_sta
tus) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool save_okay;
switch(type) switch(type)
{ {
case raw_ascii: case raw_ascii:
diskio::save_raw_ascii(*this, "[ostream]", os); save_okay = diskio::save_raw_ascii(*this, os);
break; break;
case arma_ascii: case arma_ascii:
diskio::save_arma_ascii(*this, "[ostream]", os); save_okay = diskio::save_arma_ascii(*this, os);
break; break;
case arma_binary: case arma_binary:
diskio::save_arma_binary(*this, "[ostream]", os); save_okay = diskio::save_arma_binary(*this, os);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(*this, "[ostream]", os); save_okay = diskio::save_ppm_binary(*this, os);
break; break;
default: default:
arma_stop("Cube::save(): unsupported file type"); arma_warn(print_status, "Cube::save(): unsupported file type");
save_okay = false;
} }
arma_warn( (print_status && (save_okay == false)), "Cube::save(): couldn'
t write to given stream");
return save_okay;
} }
//! load a cube from a file //! load a cube from a file
template<typename eT> template<typename eT>
inline inline
void bool
Cube<eT>::load(const std::string name, const file_type type) Cube<eT>::load(const std::string name, const file_type type, const bool pri
nt_status)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay;
std::string err_msg;
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(*this, name); load_okay = diskio::load_auto_detect(*this, name, err_msg);
break; break;
case raw_ascii: case raw_ascii:
diskio::load_raw_ascii(*this, name); load_okay = diskio::load_raw_ascii(*this, name, err_msg);
break; break;
case arma_ascii: case arma_ascii:
diskio::load_arma_ascii(*this, name); load_okay = diskio::load_arma_ascii(*this, name, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(*this, name); load_okay = diskio::load_arma_binary(*this, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(*this, name); load_okay = diskio::load_ppm_binary(*this, name, err_msg);
break; break;
default: default:
arma_stop("Cube::load(): unsupported file type"); arma_warn(print_status, "Cube::load(): unsupported file type");
load_okay = false;
}
if( (print_status == true) && (load_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("Cube::load(): ", err_msg, name);
}
else
{
arma_print("Cube::load(): couldn't read ", name);
}
}
if(load_okay == false)
{
(*this).reset();
} }
return load_okay;
} }
//! load a cube from a stream //! load a cube from a stream
template<typename eT> template<typename eT>
inline inline
void bool
Cube<eT>::load(std::istream& is, const file_type type) Cube<eT>::load(std::istream& is, const file_type type, const bool print_sta
tus)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay;
std::string err_msg;
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(*this, "[istream]", is); load_okay = diskio::load_auto_detect(*this, is, err_msg);
break; break;
case raw_ascii: case raw_ascii:
diskio::load_raw_ascii(*this, "[istream]", is); load_okay = diskio::load_raw_ascii(*this, is, err_msg);
break; break;
case arma_ascii: case arma_ascii:
diskio::load_arma_ascii(*this, "[istream]", is); load_okay = diskio::load_arma_ascii(*this, is, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(*this, "[istream]", is); load_okay = diskio::load_arma_binary(*this, is, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(*this, "[istream]", is); load_okay = diskio::load_ppm_binary(*this, is, err_msg);
break; break;
default: default:
arma_stop("Cube::load(): unsupported file type"); arma_warn(print_status, "Cube::load(): unsupported file type");
load_okay = false;
} }
if( (print_status == true) && (load_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("Cube::load(): ", err_msg, "the given stream");
}
else
{
arma_print("Cube::load(): couldn't load from the given stream");
}
}
if(load_okay == false)
{
(*this).reset();
}
return load_okay;
}
//! save the cube to a file, without printing any error messages
template<typename eT>
inline
bool
Cube<eT>::quiet_save(const std::string name, const file_type type) const
{
arma_extra_debug_sigprint();
return (*this).save(name, type, false);
}
//! save the cube to a stream, without printing any error messages
template<typename eT>
inline
bool
Cube<eT>::quiet_save(std::ostream& os, const file_type type) const
{
arma_extra_debug_sigprint();
return (*this).save(os, type, false);
}
//! load a cube from a file, without printing any error messages
template<typename eT>
inline
bool
Cube<eT>::quiet_load(const std::string name, const file_type type)
{
arma_extra_debug_sigprint();
return (*this).load(name, type, false);
}
//! load a cube from a stream, without printing any error messages
template<typename eT>
inline
bool
Cube<eT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
return (*this).load(is, type, false);
} }
template<typename eT> template<typename eT>
inline inline
typename Cube<eT>::iterator typename Cube<eT>::iterator
Cube<eT>::begin() Cube<eT>::begin()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return memptr(); return memptr();
 End of changes. 34 change blocks. 
30 lines changed or deleted 136 lines changed or added


 Cube_proto.hpp   Cube_proto.hpp 
skipping to change at line 160 skipping to change at line 160
inline void fill(const eT val); inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const u32 in_rows, const u32 in_cols, const u32 in_slic es); inline void zeros(const u32 in_rows, const u32 in_cols, const u32 in_slic es);
inline void ones(); inline void ones();
inline void ones(const u32 in_rows, const u32 in_cols, const u32 in_slice s); inline void ones(const u32 in_rows, const u32 in_cols, const u32 in_slice s);
inline void reset(); inline void reset();
inline void save(const std::string name, const file_type type = arma_bi inline bool save(const std::string name, const file_type type = arma_bi
nary) const; nary, const bool print_status = true) const;
inline void save( std::ostream& os, const file_type type = arma_bi inline bool save( std::ostream& os, const file_type type = arma_bi
nary) const; nary, const bool print_status = true) const;
inline void load(const std::string name, const file_type type = auto_de inline bool load(const std::string name, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de inline bool load( std::istream& is, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a
rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a
rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a
uto_detect);
inline bool quiet_load( std::istream& is, const file_type type = a
uto_detect);
// iterators // iterators
typedef eT* iterator; typedef eT* iterator;
typedef const eT* const_iterator; typedef const eT* const_iterator;
typedef eT* slice_iterator; typedef eT* slice_iterator;
typedef const eT* const_slice_iterator; typedef const eT* const_slice_iterator;
inline iterator begin(); inline iterator begin();
 End of changes. 2 change blocks. 
8 lines changed or deleted 18 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 2336 skipping to change at line 2336
Mat<eT>::reset() Mat<eT>::reset()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(0,0); init(0,0);
} }
//! save the matrix to a file //! save the matrix to a file
template<typename eT> template<typename eT>
inline inline
void bool
Mat<eT>::save(const std::string name, const file_type type) const Mat<eT>::save(const std::string name, const file_type type, const bool prin
t_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool save_okay;
switch(type) switch(type)
{ {
case raw_ascii: case raw_ascii:
diskio::save_raw_ascii(*this, name); save_okay = diskio::save_raw_ascii(*this, name);
break; break;
case arma_ascii: case arma_ascii:
diskio::save_arma_ascii(*this, name); save_okay = diskio::save_arma_ascii(*this, name);
break; break;
case arma_binary: case arma_binary:
diskio::save_arma_binary(*this, name); save_okay = diskio::save_arma_binary(*this, name);
break; break;
case pgm_binary: case pgm_binary:
diskio::save_pgm_binary(*this, name); save_okay = diskio::save_pgm_binary(*this, name);
break; break;
default: default:
arma_stop("Mat::save(): unsupported file type"); arma_warn(print_status, "Mat::save(): unsupported file type");
save_okay = false;
} }
arma_warn( (print_status && (save_okay == false)), "Mat::save(): couldn't
write to ", name);
return save_okay;
} }
//! save the matrix to a stream //! save the matrix to a stream
template<typename eT> template<typename eT>
inline inline
void bool
Mat<eT>::save(std::ostream& os, const file_type type) const Mat<eT>::save(std::ostream& os, const file_type type, const bool print_stat
us) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool save_okay;
switch(type) switch(type)
{ {
case raw_ascii: case raw_ascii:
diskio::save_raw_ascii(*this, "[ostream]", os); save_okay = diskio::save_raw_ascii(*this, os);
break; break;
case arma_ascii: case arma_ascii:
diskio::save_arma_ascii(*this, "[ostream]", os); save_okay = diskio::save_arma_ascii(*this, os);
break; break;
case arma_binary: case arma_binary:
diskio::save_arma_binary(*this, "[ostream]", os); save_okay = diskio::save_arma_binary(*this, os);
break; break;
case pgm_binary: case pgm_binary:
diskio::save_pgm_binary(*this, "[ostream]", os); save_okay = diskio::save_pgm_binary(*this, os);
break; break;
default: default:
arma_stop("Mat::save(): unsupported file type"); arma_warn(print_status, "Mat::save(): unsupported file type");
save_okay = false;
} }
arma_warn( (print_status && (save_okay == false)), "Mat::save(): couldn't
write to the given stream");
return save_okay;
} }
//! load a matrix from a file //! load a matrix from a file
template<typename eT> template<typename eT>
inline inline
void bool
Mat<eT>::load(const std::string name, const file_type type) Mat<eT>::load(const std::string name, const file_type type, const bool prin
t_status)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay;
std::string err_msg;
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(*this, name); load_okay = diskio::load_auto_detect(*this, name, err_msg);
break; break;
case raw_ascii: case raw_ascii:
diskio::load_raw_ascii(*this, name); load_okay = diskio::load_raw_ascii(*this, name, err_msg);
break; break;
case arma_ascii: case arma_ascii:
diskio::load_arma_ascii(*this, name); load_okay = diskio::load_arma_ascii(*this, name, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(*this, name); load_okay = diskio::load_arma_binary(*this, name, err_msg);
break; break;
case pgm_binary: case pgm_binary:
diskio::load_pgm_binary(*this, name); load_okay = diskio::load_pgm_binary(*this, name, err_msg);
break; break;
default: default:
arma_stop("Mat::load(): unsupported file type"); arma_warn(print_status, "Mat::load(): unsupported file type");
load_okay = false;
}
if( (print_status == true) && (load_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("Mat::load(): ", err_msg, name);
}
else
{
arma_print("Mat::load(): couldn't read ", name);
}
}
if(load_okay == false)
{
(*this).reset();
} }
return load_okay;
} }
//! load a matrix from a stream //! load a matrix from a stream
template<typename eT> template<typename eT>
inline inline
void bool
Mat<eT>::load(std::istream& is, const file_type type) Mat<eT>::load(std::istream& is, const file_type type, const bool print_stat
us)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay;
std::string err_msg;
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(*this, "[istream]", is); load_okay = diskio::load_auto_detect(*this, is, err_msg);
break; break;
case raw_ascii: case raw_ascii:
diskio::load_raw_ascii(*this, "[istream]", is); load_okay = diskio::load_raw_ascii(*this, is, err_msg);
break; break;
case arma_ascii: case arma_ascii:
diskio::load_arma_ascii(*this, "[istream]", is); load_okay = diskio::load_arma_ascii(*this, is, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(*this, "[istream]", is); load_okay = diskio::load_arma_binary(*this, is, err_msg);
break; break;
case pgm_binary: case pgm_binary:
diskio::load_pgm_binary(*this, "[istream]", is); load_okay = diskio::load_pgm_binary(*this, is, err_msg);
break; break;
default: default:
arma_stop("Mat::load(): unsupported file type"); arma_warn(print_status, "Mat::load(): unsupported file type");
load_okay = false;
} }
if( (print_status == true) && (load_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("Mat::load(): ", err_msg, "the given stream");
}
else
{
arma_print("Mat::load(): couldn't load from the given stream");
}
}
if(load_okay == false)
{
(*this).reset();
}
return load_okay;
}
//! save the matrix to a file, without printing any error messages
template<typename eT>
inline
bool
Mat<eT>::quiet_save(const std::string name, const file_type type) const
{
arma_extra_debug_sigprint();
return (*this).save(name, type, false);
}
//! save the matrix to a stream, without printing any error messages
template<typename eT>
inline
bool
Mat<eT>::quiet_save(std::ostream& os, const file_type type) const
{
arma_extra_debug_sigprint();
return (*this).save(os, type, false);
}
//! load a matrix from a file, without printing any error messages
template<typename eT>
inline
bool
Mat<eT>::quiet_load(const std::string name, const file_type type)
{
arma_extra_debug_sigprint();
return (*this).load(name, type, false);
}
//! load a matrix from a stream, without printing any error messages
template<typename eT>
inline
bool
Mat<eT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
return (*this).load(is, type, false);
} }
template<typename eT> template<typename eT>
inline inline
Mat<eT>::row_iterator::row_iterator(Mat<eT>& in_M, const u32 in_row) Mat<eT>::row_iterator::row_iterator(Mat<eT>& in_M, const u32 in_row)
: M (in_M ) : M (in_M )
, row(in_row) , row(in_row)
, col(0 ) , col(0 )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 34 change blocks. 
30 lines changed or deleted 136 lines changed or added


 Mat_proto.hpp   Mat_proto.hpp 
skipping to change at line 222 skipping to change at line 222
arma_hot inline void fill(const eT val); arma_hot inline void fill(const eT val);
inline void zeros(); inline void zeros();
inline void zeros(const u32 in_rows, const u32 in_cols); inline void zeros(const u32 in_rows, const u32 in_cols);
inline void ones(); inline void ones();
inline void ones(const u32 in_rows, const u32 in_cols); inline void ones(const u32 in_rows, const u32 in_cols);
inline void reset(); inline void reset();
inline void save(const std::string name, const file_type type = arma_bi inline bool save(const std::string name, const file_type type = arma_bi
nary) const; nary, const bool print_status = true) const;
inline void save( std::ostream& os, const file_type type = arma_bi inline bool save( std::ostream& os, const file_type type = arma_bi
nary) const; nary, const bool print_status = true) const;
inline void load(const std::string name, const file_type type = auto_de inline bool load(const std::string name, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de inline bool load( std::istream& is, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a
rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a
rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a
uto_detect);
inline bool quiet_load( std::istream& is, const file_type type = a
uto_detect);
// iterators // iterators
typedef eT* iterator; typedef eT* iterator;
typedef const eT* const_iterator; typedef const eT* const_iterator;
typedef eT* col_iterator; typedef eT* col_iterator;
typedef const eT* const_col_iterator; typedef const eT* const_col_iterator;
class row_iterator class row_iterator
 End of changes. 2 change blocks. 
8 lines changed or deleted 18 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 724 skipping to change at line 724
// min is used in case in_n_rows is zero // min is used in case in_n_rows is zero
Mat<eT>::ones( (std::min)( u32(1), in_n_rows), in_n_cols ); Mat<eT>::ones( (std::min)( u32(1), in_n_rows), in_n_cols );
arma_debug_check( (in_n_rows > 1), "Row<eT>::ones(): incompatible dimensi ons" ); arma_debug_check( (in_n_rows > 1), "Row<eT>::ones(): incompatible dimensi ons" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::load(const std::string name, const file_type type) Row<eT>::load(const std::string name, const file_type type, const bool prin t_status)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(name,type); Mat<eT>::load(name, type, print_status);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
void void
Row<eT>::load(std::istream& is, const file_type type) Row<eT>::load(std::istream& is, const file_type type, const bool print_stat us)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>::load(is, type); Mat<eT>::load(is, type, print_status);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Row<eT>::quiet_load(const std::string name, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(name, type);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions"
);
}
template<typename eT>
inline
void
Row<eT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
Mat<eT>::quiet_load(is, type);
arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" ); arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
} }
template<typename eT> template<typename eT>
inline inline
typename Row<eT>::row_iterator typename Row<eT>::row_iterator
Row<eT>::begin_row(const u32 row_num) Row<eT>::begin_row(const u32 row_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 4 change blocks. 
4 lines changed or deleted 30 lines changed or added


 Row_proto.hpp   Row_proto.hpp 
skipping to change at line 112 skipping to change at line 112
inline void copy_size(const Mat<eT2>& m); inline void copy_size(const Mat<eT2>& m);
inline void zeros(); inline void zeros();
inline void zeros(const u32 N); inline void zeros(const u32 N);
inline void zeros(const u32 n_rows, const u32 n_cols); inline void zeros(const u32 n_rows, const u32 n_cols);
inline void ones(); inline void ones();
inline void ones(const u32 N); inline void ones(const u32 N);
inline void ones(const u32 n_rows, const u32 n_cols); inline void ones(const u32 n_rows, const u32 n_cols);
inline void load(const std::string name, const file_type type = auto_de inline void load(const std::string name, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de inline void load( std::istream& is, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void quiet_load(const std::string name, const file_type type = a
uto_detect);
inline void quiet_load( std::istream& is, const file_type type = a
uto_detect);
typedef eT* row_iterator; typedef eT* row_iterator;
typedef const eT* const_row_iterator; typedef const eT* const_row_iterator;
inline row_iterator begin_row(const u32 row_num); inline row_iterator begin_row(const u32 row_num);
inline const_row_iterator begin_row(const u32 row_num) const; inline const_row_iterator begin_row(const u32 row_num) const;
inline row_iterator end_row (const u32 row_num); inline row_iterator end_row (const u32 row_num);
inline const_row_iterator end_row (const u32 row_num) const; inline const_row_iterator end_row (const u32 row_num) const;
}; };
 End of changes. 1 change blocks. 
4 lines changed or deleted 9 lines changed or added


 arma_version.hpp   arma_version.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
struct arma_version struct arma_version
{ {
static const unsigned int major = 0; static const unsigned int major = 0;
static const unsigned int minor = 9; static const unsigned int minor = 9;
static const unsigned int patch = 10; static const unsigned int patch = 49;
static static
inline inline
std::string std::string
as_string() as_string()
{ {
const char* nickname = "Flying Spaghetti Monster (beta)";
// http://en.wikipedia.org/wiki/Flying_Spaghetti_Monster
std::stringstream ss; std::stringstream ss;
ss << arma_version::major << '.' << arma_version::minor << '.' << arma_ ss << arma_version::major
version::patch; << '.'
<< arma_version::minor
<< '.'
<< arma_version::patch
<< " ("
<< nickname
<< ')';
return ss.str(); return ss.str();
} }
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
3 lines changed or deleted 12 lines changed or added


 armadillo   armadillo 
skipping to change at line 41 skipping to change at line 41
#include <limits> #include <limits>
#include <algorithm> #include <algorithm>
#include <complex> #include <complex>
#include <vector> #include <vector>
#if defined(ARMA_HAVE_GETTIMEOFDAY) #if defined(ARMA_HAVE_GETTIMEOFDAY)
#include <sys/time.h> #include <sys/time.h>
#undef ARMA_USE_BOOST_DATE #undef ARMA_USE_BOOST_DATE
#endif #endif
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_BOOST_DATE)
#include <boost/date_time/posix_time/posix_time.hpp>
#endif
#if defined(ARMA_HAVE_STD_TR1)
#include <tr1/cmath>
#include <tr1/complex>
#elif defined(ARMA_USE_BOOST)
#include <boost/math/complex.hpp> #include <boost/math/complex.hpp>
#include <boost/math/special_functions/acosh.hpp> #include <boost/math/special_functions/acosh.hpp>
#include <boost/math/special_functions/asinh.hpp> #include <boost/math/special_functions/asinh.hpp>
#include <boost/math/special_functions/atanh.hpp> #include <boost/math/special_functions/atanh.hpp>
#include <boost/current_function.hpp> #endif
#if defined(ARMA_USE_BOOST)
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/current_function.hpp>
#define ARMA_USE_BOOST_FORMAT #define ARMA_USE_BOOST_FORMAT
#endif #endif
#endif #endif
#if defined(ARMA_USE_BOOST_DATE)
#include <boost/date_time/posix_time/posix_time.hpp>
#endif
#if defined(ARMA_USE_ATLAS) #if defined(ARMA_USE_ATLAS)
#define ARMA_TMP_STRING(x) x
#define ARMA_ATLAS_INCLUDE_1 <ARMA_TMP_STRING(ARMA_ATLAS_INCLUDE_DIR)/ARM
A_TMP_STRING(cblas.h)>
#define ARMA_ATLAS_INCLUDE_2 <ARMA_TMP_STRING(ARMA_ATLAS_INCLUDE_DIR)/ARM
A_TMP_STRING(clapack.h)>
extern "C" #if !defined(ARMA_ATLAS_INCLUDE_DIR)
{ extern "C"
#include ARMA_ATLAS_INCLUDE_1 {
#include ARMA_ATLAS_INCLUDE_2 #include <cblas.h>
} #include <clapack.h>
}
#undef ARMA_TMP_STRING #else
#undef ARMA_ATLAS_INCLUDE_1
#undef ARMA_ATLAS_INCLUDE_2 #define ARMA_STR1(x) x
#define ARMA_STR2(x) ARMA_STR1(x)
#define ARMA_STR3(x) <x>
#define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h
)
#define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack
.h)
extern "C"
{
#include ARMA_STR3(ARMA_CBLAS)
#include ARMA_STR3(ARMA_CLAPACK)
}
#undef ARMA_STR1
#undef ARMA_STR2
#undef ARMA_STR3
#undef ARMA_CBLAS
#undef ARMA_CLAPACK
#endif
#endif #endif
#include "armadillo_bits/itpp_wrap.hpp" #include "armadillo_bits/itpp_wrap.hpp"
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
// preliminaries // preliminaries
#include "armadillo_bits/forward_proto.hpp" #include "armadillo_bits/forward_proto.hpp"
#include "armadillo_bits/arma_static_assert.hpp" #include "armadillo_bits/arma_static_assert.hpp"
#include "armadillo_bits/typedef.hpp" #include "armadillo_bits/typedef.hpp"
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/format_wrap.hpp"
#include "armadillo_bits/cmath_wrap.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
// //
skipping to change at line 188 skipping to change at line 206
#include "armadillo_bits/glue_times_proto.hpp" #include "armadillo_bits/glue_times_proto.hpp"
#include "armadillo_bits/glue_mixed_proto.hpp" #include "armadillo_bits/glue_mixed_proto.hpp"
#include "armadillo_bits/glue_cov_proto.hpp" #include "armadillo_bits/glue_cov_proto.hpp"
#include "armadillo_bits/glue_cor_proto.hpp" #include "armadillo_bits/glue_cor_proto.hpp"
#include "armadillo_bits/glue_kron_proto.hpp" #include "armadillo_bits/glue_kron_proto.hpp"
#include "armadillo_bits/glue_cross_proto.hpp" #include "armadillo_bits/glue_cross_proto.hpp"
#include "armadillo_bits/glue_join_proto.hpp" #include "armadillo_bits/glue_join_proto.hpp"
#include "armadillo_bits/glue_relational_proto.hpp" #include "armadillo_bits/glue_relational_proto.hpp"
#include "armadillo_bits/glue_solve_proto.hpp" #include "armadillo_bits/glue_solve_proto.hpp"
#include "armadillo_bits/glue_conv_proto.hpp"
// for tests & experiments #include "armadillo_bits/glue_toeplitz_proto.hpp"
// //
// debugging functions // debugging functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
// //
//
#include "armadillo_bits/cmath_wrap.hpp"
//
// classes that underlay metaprogramming // classes that underlay metaprogramming
#include "armadillo_bits/Proxy.hpp" #include "armadillo_bits/Proxy.hpp"
#include "armadillo_bits/ProxyCube.hpp" #include "armadillo_bits/ProxyCube.hpp"
#include "armadillo_bits/diagmat_proxy.hpp" #include "armadillo_bits/diagmat_proxy.hpp"
#include "armadillo_bits/unwrap.hpp" #include "armadillo_bits/unwrap.hpp"
#include "armadillo_bits/unwrap_cube.hpp" #include "armadillo_bits/unwrap_cube.hpp"
skipping to change at line 280 skipping to change at line 303
#include "armadillo_bits/fn_trans.hpp" #include "armadillo_bits/fn_trans.hpp"
#include "armadillo_bits/fn_det.hpp" #include "armadillo_bits/fn_det.hpp"
#include "armadillo_bits/fn_log_det.hpp" #include "armadillo_bits/fn_log_det.hpp"
#include "armadillo_bits/fn_eig.hpp" #include "armadillo_bits/fn_eig.hpp"
#include "armadillo_bits/fn_lu.hpp" #include "armadillo_bits/fn_lu.hpp"
#include "armadillo_bits/fn_zeros.hpp" #include "armadillo_bits/fn_zeros.hpp"
#include "armadillo_bits/fn_ones.hpp" #include "armadillo_bits/fn_ones.hpp"
#include "armadillo_bits/fn_misc.hpp" #include "armadillo_bits/fn_misc.hpp"
#include "armadillo_bits/fn_norm.hpp" #include "armadillo_bits/fn_norm.hpp"
#include "armadillo_bits/fn_dot.hpp" #include "armadillo_bits/fn_dot.hpp"
#include "armadillo_bits/fn_rand.hpp" #include "armadillo_bits/fn_randu.hpp"
#include "armadillo_bits/fn_randn.hpp" #include "armadillo_bits/fn_randn.hpp"
#include "armadillo_bits/fn_trig.hpp" #include "armadillo_bits/fn_trig.hpp"
#include "armadillo_bits/fn_mean.hpp" #include "armadillo_bits/fn_mean.hpp"
#include "armadillo_bits/fn_median.hpp" #include "armadillo_bits/fn_median.hpp"
#include "armadillo_bits/fn_stddev.hpp" #include "armadillo_bits/fn_stddev.hpp"
#include "armadillo_bits/fn_var.hpp" #include "armadillo_bits/fn_var.hpp"
#include "armadillo_bits/fn_sort.hpp" #include "armadillo_bits/fn_sort.hpp"
#include "armadillo_bits/fn_sort_index.hpp" #include "armadillo_bits/fn_sort_index.hpp"
#include "armadillo_bits/fn_htrans.hpp" #include "armadillo_bits/fn_htrans.hpp"
#include "armadillo_bits/fn_chol.hpp" #include "armadillo_bits/fn_chol.hpp"
skipping to change at line 310 skipping to change at line 333
#include "armadillo_bits/fn_eps.hpp" #include "armadillo_bits/fn_eps.hpp"
#include "armadillo_bits/fn_pinv.hpp" #include "armadillo_bits/fn_pinv.hpp"
#include "armadillo_bits/fn_rank.hpp" #include "armadillo_bits/fn_rank.hpp"
#include "armadillo_bits/fn_kron.hpp" #include "armadillo_bits/fn_kron.hpp"
#include "armadillo_bits/fn_flip.hpp" #include "armadillo_bits/fn_flip.hpp"
#include "armadillo_bits/fn_as_scalar.hpp" #include "armadillo_bits/fn_as_scalar.hpp"
#include "armadillo_bits/fn_princomp.hpp" #include "armadillo_bits/fn_princomp.hpp"
#include "armadillo_bits/fn_princomp_cov.hpp" #include "armadillo_bits/fn_princomp_cov.hpp"
#include "armadillo_bits/fn_cross.hpp" #include "armadillo_bits/fn_cross.hpp"
#include "armadillo_bits/fn_join.hpp" #include "armadillo_bits/fn_join.hpp"
#include "armadillo_bits/fn_conv.hpp"
#include "armadillo_bits/fn_trunc_exp.hpp"
#include "armadillo_bits/fn_trunc_log.hpp"
#include "armadillo_bits/fn_toeplitz.hpp"
// //
// class meat // class meat
#include "armadillo_bits/gemm.hpp" #include "armadillo_bits/gemm.hpp"
#include "armadillo_bits/gemv.hpp" #include "armadillo_bits/gemv.hpp"
#include "armadillo_bits/gemm_mixed.hpp" #include "armadillo_bits/gemm_mixed.hpp"
#include "armadillo_bits/eop_core_meat.hpp" #include "armadillo_bits/eop_core_meat.hpp"
#include "armadillo_bits/eop_cube_core_meat.hpp" #include "armadillo_bits/eop_cube_core_meat.hpp"
skipping to change at line 382 skipping to change at line 409
#include "armadillo_bits/glue_times_meat.hpp" #include "armadillo_bits/glue_times_meat.hpp"
#include "armadillo_bits/glue_mixed_meat.hpp" #include "armadillo_bits/glue_mixed_meat.hpp"
#include "armadillo_bits/glue_cov_meat.hpp" #include "armadillo_bits/glue_cov_meat.hpp"
#include "armadillo_bits/glue_cor_meat.hpp" #include "armadillo_bits/glue_cor_meat.hpp"
#include "armadillo_bits/glue_kron_meat.hpp" #include "armadillo_bits/glue_kron_meat.hpp"
#include "armadillo_bits/glue_cross_meat.hpp" #include "armadillo_bits/glue_cross_meat.hpp"
#include "armadillo_bits/glue_join_meat.hpp" #include "armadillo_bits/glue_join_meat.hpp"
#include "armadillo_bits/glue_relational_meat.hpp" #include "armadillo_bits/glue_relational_meat.hpp"
#include "armadillo_bits/glue_solve_meat.hpp" #include "armadillo_bits/glue_solve_meat.hpp"
#include "armadillo_bits/glue_conv_meat.hpp"
#include "armadillo_bits/glue_toeplitz_meat.hpp"
} }
#endif #endif
 End of changes. 13 change blocks. 
25 lines changed or deleted 54 lines changed or added


 atlas_proto.hpp   atlas_proto.hpp 
skipping to change at line 26 skipping to change at line 26
#ifdef ARMA_USE_ATLAS #ifdef ARMA_USE_ATLAS
//! \namespace atlas namespace for ATLAS functions (imported from the globa l namespace) //! \namespace atlas namespace for ATLAS functions (imported from the globa l namespace)
namespace atlas namespace atlas
{ {
using ::CblasColMajor; using ::CblasColMajor;
using ::CblasNoTrans; using ::CblasNoTrans;
using ::CblasTrans; using ::CblasTrans;
// using ::cblas_sdot; using ::cblas_sdot;
// using ::cblas_ddot; using ::cblas_ddot;
// using ::cblas_cdotu_sub; using ::cblas_cdotu_sub;
// using ::cblas_zdotu_sub; using ::cblas_zdotu_sub;
using ::cblas_sgemv; using ::cblas_sgemv;
using ::cblas_dgemv; using ::cblas_dgemv;
using ::cblas_cgemv; using ::cblas_cgemv;
using ::cblas_zgemv; using ::cblas_zgemv;
using ::cblas_sgemm; using ::cblas_sgemm;
using ::cblas_dgemm; using ::cblas_dgemm;
using ::cblas_cgemm; using ::cblas_cgemm;
using ::cblas_zgemm; using ::cblas_zgemm;
skipping to change at line 57 skipping to change at line 57
using ::clapack_dgetri; using ::clapack_dgetri;
using ::clapack_cgetri; using ::clapack_cgetri;
using ::clapack_zgetri; using ::clapack_zgetri;
template<typename eT> template<typename eT>
inline static const eT& tmp_real(const eT& X) { return X; } inline static const eT& tmp_real(const eT& X) { return X; }
template<typename T> template<typename T>
inline static const T& tmp_real(const std::complex<T>& X) { return X.rea l(); } inline static const T& tmp_real(const std::complex<T>& X) { return X.rea l(); }
// template<typename eT> template<typename eT>
// inline arma_inline
// void eT
// cblas_dot(const int N, const eT *X, const int incX, const eT *Y, const cblas_dot(const int N, const eT* X, const eT* Y)
int incY, eT& out) {
// { arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
// arma_type_check<is_supported_blas_type<eT>::value == false>::apply()
; if(is_float<eT>::value == true)
// {
// if(is_float<eT>::value == true) typedef float T;
// { return eT( cblas_sdot(N, (const T*)X, 1, (const T*)Y, 1) );
// typedef float T; }
// out = eT( cblas_sdot(N, (const T*)X, incX, (const T*)Y, incY) ); else
// } if(is_double<eT>::value == true)
// else {
// if(is_double<eT>::value == true) typedef double T;
// { return eT( cblas_ddot(N, (const T*)X, 1, (const T*)Y, 1) );
// typedef double T; }
// out = eT( cblas_ddot(N, (const T*)X, incX, (const T*)Y, incY) ); else
// } {
// else return eT(0);
// if(is_supported_complex_float<eT>::value == true) }
// { }
// typedef std::complex<float> T;
// cblas_cdotu_sub(N, (const T*)X, incX, (const T*)Y, incY, (T*)&out) template<typename eT>
; arma_inline
// } eT
// else cx_cblas_dot(const int N, const eT* X, const eT* Y)
// if(is_supported_complex_double<eT>::value == true) {
// { arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
// typedef std::complex<double> T;
// cblas_zdotu_sub(N, (const T*)X, incX, (const T*)Y, incY, (T*)&out) if(is_supported_complex_float<eT>::value == true)
; {
// } typedef typename std::complex<float> T;
// }
T out;
cblas_cdotu_sub(N, (const T*)X, 1, (const T*)Y, 1, &out);
return eT(out);
}
else
if(is_supported_complex_double<eT>::value == true)
{
typedef typename std::complex<double> T;
T out;
cblas_zdotu_sub(N, (const T*)X, 1, (const T*)Y, 1, &out);
return eT(out);
}
else
{
return eT(0);
}
}
template<typename eT> template<typename eT>
inline inline
void void
cblas_gemv cblas_gemv
( (
const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const int M, const int N, const int M, const int N,
const eT alpha, const eT alpha,
const eT *A, const int lda, const eT *A, const int lda,
 End of changes. 2 change blocks. 
39 lines changed or deleted 59 lines changed or added


 blas_proto.hpp   blas_proto.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
#ifdef ARMA_USE_BLAS #ifdef ARMA_USE_BLAS
//! \namespace blas namespace for BLAS functions //! \namespace blas namespace for BLAS functions
namespace blas namespace blas
{ {
extern "C" extern "C"
{ {
float sdot_(const int* n, const float* x, const int* incx, const floa
t* y, const int* incy);
double ddot_(const int* n, const double* x, const int* incx, const doub
le* y, const int* incy);
void sgemv_(const char* transA, const int* m, const int* n, const float * alpha, const float* A, const int* ldA, const float* x, const int* incx , const float* beta, float* y, const int* incy); void sgemv_(const char* transA, const int* m, const int* n, const float * alpha, const float* A, const int* ldA, const float* x, const int* incx , const float* beta, float* y, const int* incy);
void dgemv_(const char* transA, const int* m, const int* n, const doubl e* alpha, const double* A, const int* ldA, const double* x, const int* incx , const double* beta, double* y, const int* incy); void dgemv_(const char* transA, const int* m, const int* n, const doubl e* alpha, const double* A, const int* ldA, const double* x, const int* incx , const double* beta, double* y, const int* incy);
void cgemv_(const char* transA, const int* m, const int* n, const void* alpha, const void* A, const int* ldA, const void* x, const int* incx , const void* beta, void* y, const int* incy); void cgemv_(const char* transA, const int* m, const int* n, const void* alpha, const void* A, const int* ldA, const void* x, const int* incx , const void* beta, void* y, const int* incy);
void zgemv_(const char* transA, const int* m, const int* n, const void* alpha, const void* A, const int* ldA, const void* x, const int* incx , const void* beta, void* y, const int* incy); void zgemv_(const char* transA, const int* m, const int* n, const void* alpha, const void* A, const int* ldA, const void* x, const int* incx , const void* beta, void* y, const int* incy);
void sgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const float* alpha, const float* A, const int* ldA , const float* B, const int* ldB, const float* beta, float* C, const int * ldC); void sgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const float* alpha, const float* A, const int* ldA , const float* B, const int* ldB, const float* beta, float* C, const int * ldC);
void dgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const double* alpha, const double* A, const int* ldA , const double* B, const int* ldB, const double* beta, double* C, const int * ldC); void dgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const double* alpha, const double* A, const int* ldA , const double* B, const int* ldB, const double* beta, double* C, const int * ldC);
void cgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const void* alpha, const void* A, const int* ldA , const void* B, const int* ldB, const void* beta, void* C, const int * ldC); void cgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const void* alpha, const void* A, const int* ldA , const void* B, const int* ldB, const void* beta, void* C, const int * ldC);
void zgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const void* alpha, const void* A, const int* ldA , const void* B, const int* ldB, const void* beta, void* C, const int * ldC); void zgemm_(const char* transA, const char* transB, const int* m, const int* n, const int* k, const void* alpha, const void* A, const int* ldA , const void* B, const int* ldB, const void* beta, void* C, const int * ldC);
// float sdot_(const int* n, const float* x, const int* incx, const f // void dswap_(const int* n, double* x, const int* incx, double* y, c
loat* y, const int* incy); onst int* incy);
// double ddot_(const int* n, const double* x, const int* incx, const d // void dscal_(const int* n, const double* alpha, double* x, const in
ouble* y, const int* incy); t* incx);
// void dcopy_(const int* n, const double* x, const int* incx, double
// void dswap_(const int* n, double* x, const int* incx, double* y, c * y, const int* incy);
onst int* incy); // void daxpy_(const int* n, const double* alpha, const double* x, co
// void dscal_(const int* n, const double* alpha, double* x, const in nst int* incx, double* y, const int* incy);
t* incx); // void dger_(const int* m, const int* n, const double* alpha, const
// void dcopy_(const int* n, const double* x, const int* incx, double double* x, const int* incx, const double* y, const int* incy, double* A, c
* y, const int* incy); onst int* ldA);
// void daxpy_(const int* n, const double* alpha, const double* x, co
nst int* incx, double* y, const int* incy);
// void dger_(const int* m, const int* n, const double* alpha, const
double* x, const int* incx, const double* y, const int* incy, double* A, c
onst int* ldA);
} }
// template<typename eT> template<typename eT>
// inline arma_inline
// eT eT
// dot_(const int* n, const eT* x, const int* incx, const eT* y, const in dot_(const int* n, const eT* x, const eT* y)
t* incy) {
// { arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
// arma_type_check<is_supported_blas_type<eT>::value == false>::apply()
; const int inc = 1;
//
// if(is_float<eT>::value == true) if(is_float<eT>::value == true)
// { {
// typedef float T; typedef float T;
// return sdot_(n, (const T*)x, incx, (const T*)y, incy); return eT( sdot_(n, (const T*)x, &inc, (const T*)y, &inc) );
// } }
// else else
// if(is_double<eT>::value == true) if(is_double<eT>::value == true)
// { {
// typedef double T; typedef double T;
// return ddot_(n, (const T*)x, incx, (const T*)y, incy); return eT( ddot_(n, (const T*)x, &inc, (const T*)y, &inc) );
// } }
// else
// return eT(); // prevent compiler warnings {
// } return eT(0); // prevent compiler warnings
}
}
template<typename eT> template<typename eT>
inline inline
void void
gemv_(const char* transA, const int* m, const int* n, const eT* alpha, co nst eT* A, const int* ldA, const eT* x, const int* incx, const eT* beta, eT * y, const int* incy) gemv_(const char* transA, const int* m, const int* n, const eT* alpha, co nst eT* A, const int* ldA, const eT* x, const int* incx, const eT* beta, eT * y, const int* incy)
{ {
arma_type_check<is_supported_blas_type<eT>::value == false>::apply(); arma_type_check<is_supported_blas_type<eT>::value == false>::apply();
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
 End of changes. 3 change blocks. 
39 lines changed or deleted 41 lines changed or added


 cmath_wrap.hpp   cmath_wrap.hpp 
skipping to change at line 19 skipping to change at line 19
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup cmath_wrap //! \addtogroup cmath_wrap
//! @{ //! @{
//
// wrappers for isfinite
//
template<typename eT> template<typename eT>
arma_inline arma_inline
bool bool
arma_isfinite(eT val) arma_isfinite(eT val)
{ {
return true; return true;
} }
template<> template<>
arma_inline arma_inline
skipping to change at line 80 skipping to change at line 84
if( (arma_isfinite(x.real()) == false) || (arma_isfinite(x.imag()) == fal se) ) if( (arma_isfinite(x.real()) == false) || (arma_isfinite(x.imag()) == fal se) )
{ {
return false; return false;
} }
else else
{ {
return true; return true;
} }
} }
//
// wrappers for trigonometric functions
//
// Wherever possible, try to use TR1 versions of the functions below,
// otherwise fall back to Boost Math.
//
// complex acos
// complex asin
// complex atan
//
// real acosh
// real asinh
// real atanh
//
// complex acosh
// complex asinh
// complex atanh
//
//
// If TR1 not present and Boost math not present,
// we have our own rudimentary versions of:
//
// real acosh
// real asinh
// real atanh
#if defined(ARMA_USE_BOOST)
#define arma_boost_wrap(trig_fn, val) ( (boost::math::trig_fn)(val) )
#else
#define arma_boost_wrap(trig_fn, val) ( arma_stop( #trig_fn "(): need Boo
st libraries" ), val )
#endif
template<typename T>
arma_inline
std::complex<T>
arma_acos(const std::complex<T>& x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::acos(x);
}
#else
{
return arma_boost_wrap(acos, x);
}
#endif
}
template<typename T>
arma_inline
std::complex<T>
arma_asin(const std::complex<T>& x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::asin(x);
}
#else
{
return arma_boost_wrap(asin, x);
}
#endif
}
template<typename T>
arma_inline
std::complex<T>
arma_atan(const std::complex<T>& x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::atan(x);
}
#else
{
return arma_boost_wrap(atan, x);
}
#endif
}
template<typename eT>
arma_inline
eT
arma_acosh(const eT x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::acosh(x);
}
#elif defined(ARMA_USE_BOOST)
{
return boost::math::acosh(x);
}
#else
{
if(x >= eT(1))
{
// http://functions.wolfram.com/ElementaryFunctions/ArcCosh/02/
return std::log( x + std::sqrt(x*x - eT(1)) );
}
else
{
if(std::numeric_limits<eT>::has_quiet_NaN == true)
{
return -(std::numeric_limits<eT>::quiet_NaN());
}
else
{
return eT(0);
}
}
}
#endif
}
template<typename eT>
arma_inline
eT
arma_asinh(const eT x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::asinh(x);
}
#elif defined(ARMA_USE_BOOST)
{
return boost::math::asinh(x);
}
#else
{
// http://functions.wolfram.com/ElementaryFunctions/ArcSinh/02/
return std::log( x + std::sqrt(x*x + eT(1)) );
}
#endif
}
template<typename eT>
arma_inline
eT
arma_atanh(const eT x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::atanh(x);
}
#elif defined(ARMA_USE_BOOST)
{
return boost::math::atanh(x);
}
#else
{
if( (x >= eT(-1)) && (x <= eT(+1)) )
{
// http://functions.wolfram.com/ElementaryFunctions/ArcTanh/02/
return std::log( ( eT(1)+x ) / ( eT(1)-x ) ) / eT(2);
}
else
{
if(std::numeric_limits<eT>::has_quiet_NaN == true)
{
return -(std::numeric_limits<eT>::quiet_NaN());
}
else
{
return eT(0);
}
}
}
#endif
}
template<typename T>
arma_inline
std::complex<T>
arma_acosh(const std::complex<T>& x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::acosh(x);
}
#else
{
return arma_boost_wrap(acosh, x);
}
#endif
}
template<typename T>
arma_inline
std::complex<T>
arma_asinh(const std::complex<T>& x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::asinh(x);
}
#else
{
return arma_boost_wrap(asinh, x);
}
#endif
}
template<typename T>
arma_inline
std::complex<T>
arma_atanh(const std::complex<T>& x)
{
#if defined(ARMA_HAVE_STD_TR1)
{
return std::tr1::atanh(x);
}
#else
{
return arma_boost_wrap(atanh, x);
}
#endif
}
#undef arma_boost_wrap
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 227 lines changed or added


 compiler_setup.hpp   compiler_setup.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
#define arma_hot #define arma_hot
#define arma_cold #define arma_cold
#define arma_pure #define arma_pure
#define arma_const #define arma_const
#define arma_inline inline #define arma_inline inline
#define arma_aligned #define arma_aligned
#define arma_warn_unused #define arma_warn_unused
#define arma_deprecated
#if defined(__GNUG__) #if defined(__GNUG__)
#if (__GNUC__ < 4) #if (__GNUC__ < 4)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#if (__GNUC_MINOR__ >= 3) #define ARMA_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNU
#undef arma_hot C_PATCHLEVEL__)
#undef arma_cold
#define arma_hot __attribute__((hot)) #define ARMA_GOOD_COMPILER
#define arma_cold __attribute__((cold)) #undef ARMA_HAVE_STD_TR1
#endif
#undef arma_pure #undef arma_pure
#undef arma_const #undef arma_const
#undef arma_inline #undef arma_inline
#undef arma_aligned #undef arma_aligned
#undef arma_warn_unused #undef arma_warn_unused
#undef arma_deprecated
#define arma_pure __attribute__((pure)) #define arma_pure __attribute__((pure))
#define arma_const __attribute__((const)) #define arma_const __attribute__((const))
#define arma_inline inline __attribute__((always_inline)) #define arma_inline inline __attribute__((always_inline))
#define arma_aligned __attribute__((aligned)) #define arma_aligned __attribute__((aligned))
#define arma_warn_unused __attribute__((warn_unused_result)) #define arma_warn_unused __attribute__((warn_unused_result))
#define arma_deprecated __attribute__((deprecated))
#define ARMA_GOOD_COMPILER #if (ARMA_GCC_VERSION >= 40200)
#define ARMA_HAVE_STD_TR1
#endif
#if (ARMA_GCC_VERSION >= 40300)
#undef arma_hot
#undef arma_cold
#define arma_hot __attribute__((hot))
#define arma_cold __attribute__((cold))
#endif
#undef ARMA_GCC_VERSION
#elif defined(__INTEL_COMPILER) #elif defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER < 1000) #if (__INTEL_COMPILER < 1000)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#define ARMA_GOOD_COMPILER #define ARMA_GOOD_COMPILER
#undef ARMA_HAVE_STD_TR1
#if (__INTEL_COMPILER <= 1110)
#undef ARMA_HAVE_STD_ISFINITE
#endif
#endif
#elif defined(_MSC_VER) #if defined(_MSC_VER)
#pragma message ("*** WARNING: This compiler may have an incomplete imple mentation of the C++ standard ***") #pragma message ("*** WARNING: This compiler may have an incomplete imple mentation of the C++ standard ***")
#undef ARMA_GOOD_COMPILER #undef ARMA_GOOD_COMPILER
#undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_SNPRINTF
#undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF
#undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1
#undef arma_inline
#define arma_inline inline __forceinline
#endif #endif
#if defined(__CUDACC__) #if defined(__CUDACC__)
#undef ARMA_HAVE_STD_ISFINITE #undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_SNPRINTF
#undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF #undef ARMA_HAVE_STD_ISINF
#undef ARMA_HAVE_STD_ISNAN #undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1
#endif #endif
#if defined(__INTEL_COMPILER) #if defined(__SUNPRO_CC)
#if (__INTEL_COMPILER <= 1110) #undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_ISFINITE #undef ARMA_HAVE_STD_SNPRINTF
#endif #undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF
#undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1
#endif #endif
 End of changes. 13 change blocks. 
12 lines changed or deleted 48 lines changed or added


 config.hpp   config.hpp 
skipping to change at line 16 skipping to change at line 16
// //
// This file is part of the Armadillo C++ library. // This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness // It is provided without any warranty of fitness
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
#if !defined(ARMA_USE_LAPACK)
#define ARMA_USE_LAPACK
#endif
#if !defined(ARMA_USE_BLAS)
#define ARMA_USE_BLAS
#endif
#define ARMA_USE_ATLAS
#define ARMA_ATLAS_INCLUDE_DIR /usr/include/
//// If you're using ATLAS and the compiler can't find cblas.h and/or clapa
ck.h
//// uncomment the above define and specify the appropriate include directo
ry.
//// Make sure the directory has a trailing /
#define ARMA_USE_BOOST
#define ARMA_USE_BOOST_DATE
#define ARMA_HAVE_STD_ISFINITE #define ARMA_HAVE_STD_ISFINITE
#define ARMA_HAVE_STD_ISINF #define ARMA_HAVE_STD_ISINF
#define ARMA_HAVE_STD_ISNAN #define ARMA_HAVE_STD_ISNAN
#define ARMA_HAVE_STD_SNPRINTF #define ARMA_HAVE_STD_SNPRINTF
#define ARMA_HAVE_LOG1P #define ARMA_HAVE_LOG1P
#define ARMA_HAVE_GETTIMEOFDAY #define ARMA_HAVE_GETTIMEOFDAY
#define ARMA_USE_ATLAS
#define ARMA_USE_LAPACK
#define ARMA_USE_BLAS
#define ARMA_USE_BOOST
#define ARMA_USE_BOOST_DATE
/* #undef ARMA_EXTRA_DEBUG */ /* #undef ARMA_EXTRA_DEBUG */
/* #undef ARMA_NO_DEBUG */ /* #undef ARMA_NO_DEBUG */
#if defined(ARMA_USE_ATLAS)
#if !defined(ARMA_ATLAS_INCLUDE_DIR)
#define ARMA_ATLAS_INCLUDE_DIR /usr/include
#endif
#endif
 End of changes. 3 change blocks. 
6 lines changed or deleted 19 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 26 skipping to change at line 26
//! \addtogroup debug //! \addtogroup debug
//! @{ //! @{
// //
// arma_stop // arma_stop
//! print a message to std::cout and/or throw a run-time error exception //! print a message to std::cout and/or throw a run-time error exception
template<typename T1> template<typename T1>
inline inline
void void
arma_cold
arma_stop(const T1& x) arma_stop(const T1& x)
{ {
std::cerr.flush(); std::cerr.flush();
std::cout.flush(); std::cout.flush();
std::cout << '\n'; std::cout << '\n';
std::cout << "run-time error: " << x << '\n'; std::cout << "run-time error: " << x << '\n';
std::cout << '\n'; std::cout << '\n';
std::cout.flush(); std::cout.flush();
throw std::runtime_error(""); throw std::runtime_error("");
} }
// //
// arma_print // arma_print
inline inline
void void
arma_cold
arma_print() arma_print()
{ {
std::cout << std::endl; std::cout << std::endl;
} }
template<typename T1> template<typename T1>
inline inline
void void
arma_cold
arma_print(const T1& x) arma_print(const T1& x)
{ {
std::cout << x << std::endl; std::cout << x << std::endl;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
arma_cold
arma_print(const T1& x, const T2& y) arma_print(const T1& x, const T2& y)
{ {
std::cout << x << y << std::endl; std::cout << x << y << std::endl;
} }
#ifdef ARMA_USE_BOOST_FORMAT template<typename T1, typename T2, typename T3>
template<typename T1> inline
inline void
void arma_cold
arma_print(const arma_boost::basic_format<T1>& x) arma_print(const T1& x, const T2& y, const T3& z)
{ {
std::cout << x << std::endl; std::cout << x << y << z << std::endl;
} }
#else
template<typename T1, typename T2>
inline
void
arma_print(const arma_boost::basic_format<T1,T2>& x)
{
std::cout << x << std::endl;
}
#endif
// //
// arma_sigprint // arma_sigprint
//! print a message on cout, with a preceding @ character. //! print a message on cout, with a preceding @ character.
//! used for printing the signature of a function //! used for printing the signature of a function
//! (see the arma_extra_debug_sigprint macro) //! (see the arma_extra_debug_sigprint macro)
inline inline
void void
arma_sigprint(const char* x) arma_sigprint(const char* x)
skipping to change at line 122 skipping to change at line 117
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
arma_bktprint(const T1& x, const T2& y) arma_bktprint(const T1& x, const T2& y)
{ {
std::cout << " [" << x << y << ']' << std::endl; std::cout << " [" << x << y << ']' << std::endl;
} }
#ifdef ARMA_USE_BOOST_FORMAT
template<typename T1>
inline
void
arma_bktprint(const arma_boost::basic_format<T1>& x)
{
std::cout << " [" << x << ']' << std::endl;
}
#else
template<typename T1, typename T2>
inline
void
arma_bktprint(const arma_boost::basic_format<T1,T2>& x)
{
std::cout << " [" << x << ']' << std::endl;
}
#endif
// //
// arma_thisprint // arma_thisprint
inline inline
void void
arma_thisprint(void* this_ptr) arma_thisprint(void* this_ptr)
{ {
std::cout << " [this = " << this_ptr << ']' << std::endl; std::cout << " [this = " << this_ptr << ']' << std::endl;
} }
skipping to change at line 178 skipping to change at line 155
void void
arma_hot arma_hot
arma_warn(const bool state, const T1& x, const T2& y) arma_warn(const bool state, const T1& x, const T2& y)
{ {
if(state==true) if(state==true)
{ {
arma_print(x,y); arma_print(x,y);
} }
} }
#ifdef ARMA_USE_BOOST_FORMAT
template<typename T1>
inline
void
arma_hot
arma_warn(const bool state, const arma_boost::basic_format<T1>& x)
{
if(state==true)
arma_print(x);
}
#else
template<typename T1, typename T2>
inline
void
arma_hot
arma_warn(const bool state, const arma_boost::basic_format<T1,T2>& x)
{
if(state==true)
arma_print(x);
}
#endif
// //
// arma_check // arma_check
//! if state is true, abort program //! if state is true, abort program
template<typename T1> template<typename T1>
inline inline
void void
arma_hot arma_hot
arma_check(const bool state, const T1& x) arma_check(const bool state, const T1& x)
{ {
if(state==true) if(state==true)
{ {
arma_stop(x); arma_stop(arma_boost::str_wrapper(x));
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
arma_hot arma_hot
arma_check(const bool state, const T1& x, const T2& y) arma_check(const bool state, const T1& x, const T2& y)
{ {
if(state==true) if(state==true)
{ {
arma_stop( std::string(x) + std::string(y) ); arma_stop( std::string(x) + std::string(y) );
} }
} }
#ifdef ARMA_USE_BOOST_FORMAT
template<typename T1>
inline
void
arma_hot
arma_check(const bool state, const arma_boost::basic_format<T1>& x)
{
if(state==true)
{
arma_stop(str(x));
}
}
#else
template<typename T1, typename T2>
inline
void
arma_hot
arma_check(const bool state, const arma_boost::basic_format<T1,T2>& x)
{
if(state==true)
{
arma_stop(str(x));
}
}
#endif
// //
// functions for checking whether two matrices have the same dimensions // functions for checking whether two matrices have the same dimensions
inline inline
std::string std::string
arma_cold
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_rows, const u32 B_n_cols, const char* x) arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 B_n_rows, const u32 B_n_cols, const char* x)
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << x << ": incompatible matrix dimensions: (" << A_n_rows << ',' << A _n_cols << ") and (" << B_n_rows << ',' << B_n_cols << ')'; tmp << x << ": incompatible matrix dimensions: (" << A_n_rows << ',' << A _n_cols << ") and (" << B_n_rows << ',' << B_n_cols << ')';
return tmp.str(); return tmp.str();
} }
inline inline
skipping to change at line 393 skipping to change at line 323
if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) ) if( (A.n_rows != B.n_rows) || (A.n_cols != B.n_cols) )
{ {
arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_ cols, x) ); arma_stop( arma_incompat_size_string(A.n_rows, A.n_cols, B.n_rows, B.n_ cols, x) );
} }
} }
// //
// functions for checking whether two cubes have the same dimensions // functions for checking whether two cubes have the same dimensions
inline inline
arma_cold
std::string std::string
arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 A_n_slices, const u32 B_n_rows, const u32 B_n_cols, const u32 B_n_slices, const char* x) arma_incompat_size_string(const u32 A_n_rows, const u32 A_n_cols, const u32 A_n_slices, const u32 B_n_rows, const u32 B_n_cols, const u32 B_n_slices, const char* x)
{ {
std::stringstream tmp; std::stringstream tmp;
tmp << x << ": incompatible cube dimensions: (" << A_n_rows << ',' << A_n _cols << ',' << A_n_slices << ") and (" << B_n_rows << ',' << B_n_cols << ' ,' << B_n_slices << ')'; tmp << x << ": incompatible cube dimensions: (" << A_n_rows << ',' << A_n _cols << ',' << A_n_slices << ") and (" << B_n_rows << ',' << B_n_cols << ' ,' << B_n_slices << ')';
return tmp.str(); return tmp.str();
} }
skipping to change at line 673 skipping to change at line 604
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
namespace junk namespace junk
{ {
class arma_first_extra_debug_message class arma_first_extra_debug_message
{ {
public: public:
inline inline
arma_cold
arma_first_extra_debug_message() arma_first_extra_debug_message()
{ {
std::cout << "@ ---" << '\n'; std::cout << "@ ---" << '\n';
std::cout << "@ Armadillo " << arma_version::major << '.' << arma_v ersion::minor << '.' << arma_version::patch << '\n'; std::cout << "@ Armadillo " << arma_version::major << '.' << arma_v ersion::minor << '.' << arma_version::patch << '\n';
std::cout << "@ arma_config::atlas = " << arma_config::atlas << '\n'; std::cout << "@ arma_config::atlas = " << arma_config::atlas << '\n';
std::cout << "@ arma_config::lapack = " << arma_config::lapack << '\n'; std::cout << "@ arma_config::lapack = " << arma_config::lapack << '\n';
std::cout << "@ arma_config::blas = " << arma_config::blas << '\n'; std::cout << "@ arma_config::blas = " << arma_config::blas << '\n';
std::cout << "@ arma_config::boost = " << arma_config::boost << '\n'; std::cout << "@ arma_config::boost = " << arma_config::boost << '\n';
std::cout << "@ arma_config::boost_date = " << arma_config::boost_d ate << '\n'; std::cout << "@ arma_config::boost_date = " << arma_config::boost_d ate << '\n';
std::cout << "@ arma_config::good_comp = " << arma_config::good_co mp << '\n'; std::cout << "@ arma_config::good_comp = " << arma_config::good_co mp << '\n';
 End of changes. 12 change blocks. 
84 lines changed or deleted 16 lines changed or added


 diskio_meat.hpp   diskio_meat.hpp 
skipping to change at line 401 skipping to change at line 401
return out; return out;
} }
//! Safely rename a file. //! Safely rename a file.
//! Before renaming, test if we can write to the final file. //! Before renaming, test if we can write to the final file.
//! This should prevent: //! This should prevent:
//! (i) overwriting files that have been write protected, //! (i) overwriting files that have been write protected,
//! (ii) overwriting directories. //! (ii) overwriting directories.
inline inline
void bool
diskio::safe_rename(const std::string& old_name, const std::string& new_nam e) diskio::safe_rename(const std::string& old_name, const std::string& new_nam e)
{ {
std::fstream f(new_name.c_str(), std::fstream::out | std::fstream::app); std::fstream f(new_name.c_str(), std::fstream::out | std::fstream::app);
f.put(' '); f.put(' ');
const bool writing_problem = (f.good() == false); bool save_okay = f.good();
f.close(); f.close();
arma_warn( writing_problem, "trouble writing ", new_name ); if(save_okay == true)
if(writing_problem == false)
{ {
std::remove(new_name.c_str()); std::remove(new_name.c_str());
const int mv_result = std::rename(old_name.c_str(), new_name.c_str()); const int mv_result = std::rename(old_name.c_str(), new_name.c_str());
arma_warn( (mv_result != 0), "trouble writing ", new_name );
save_okay = (mv_result == 0);
} }
return save_okay;
} }
//! Save a matrix as raw text (no header, human readable). //! Save a matrix as raw text (no header, human readable).
//! Matrices can be loaded in Matlab and Octave, as long as they don't have complex elements. //! Matrices can be loaded in Matlab and Octave, as long as they don't have complex elements.
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_raw_ascii(const Mat<eT>& x, const std::string& final_name) diskio::save_raw_ascii(const Mat<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::fstream f(tmp_name.c_str(), std::fstream::out); std::fstream f(tmp_name.c_str(), std::fstream::out);
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("unable to write ", tmp_name); if(save_okay == true)
}
else
{ {
diskio::save_raw_ascii(x, tmp_name, f); save_okay = diskio::save_raw_ascii(x, f);
const bool writing_problem = (f.good() == false);
f.flush(); f.flush();
f.close(); f.close();
arma_warn(writing_problem, "trouble writing ", tmp_name); if(save_okay == true)
if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
//! Save a matrix as raw text (no header, human readable). //! Save a matrix as raw text (no header, human readable).
//! Matrices can be loaded in Matlab and Octave, as long as they don't have complex elements. //! Matrices can be loaded in Matlab and Octave, as long as they don't have complex elements.
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_raw_ascii(const Mat<eT>& x, const std::string& name, std::ostr diskio::save_raw_ascii(const Mat<eT>& x, std::ostream& f)
eam& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 cell_width; u32 cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
skipping to change at line 492 skipping to change at line 489
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col); f << x.at(row,col);
} }
f.put('\n'); f.put('\n');
} }
return f.good();
} }
//! Save a matrix in text format (human readable), //! Save a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions //! with a header that indicates the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_ascii(const Mat<eT>& x, const std::string& final_name) diskio::save_arma_ascii(const Mat<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str()); std::ofstream f(tmp_name.c_str());
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_debug_print("unable to write ", tmp_name);
}
else
{
diskio::save_arma_ascii(x, tmp_name, f);
const bool writing_problem = (f.good() == false); if(save_okay == true)
{
save_okay = diskio::save_arma_ascii(x, f);
f.flush(); f.flush();
f.close(); f.close();
arma_warn( writing_problem, "trouble writing ", tmp_name ); if(save_okay == true)
if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
//! Save a matrix in text format (human readable), //! Save a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions //! with a header that indicates the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_ascii(const Mat<eT>& x, const std::string& name, std::ost diskio::save_arma_ascii(const Mat<eT>& x, std::ostream& f)
ream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const ios::fmtflags orig_flags = f.flags(); const ios::fmtflags orig_flags = f.flags();
f << diskio::gen_txt_header(x) << '\n'; f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << '\n'; f << x.n_rows << ' ' << x.n_cols << '\n';
u32 cell_width; u32 cell_width;
skipping to change at line 571 skipping to change at line 566
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col); f << x.at(row,col);
} }
f.put('\n'); f.put('\n');
} }
const bool save_okay = f.good();
f.flags(orig_flags); f.flags(orig_flags);
return save_okay;
} }
//! Save a matrix in binary format, //! Save a matrix in binary format,
//! with a header that stores the matrix type as well as its dimensions //! with a header that stores the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_binary(const Mat<eT>& x, const std::string& final_name) diskio::save_arma_binary(const Mat<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str(), std::fstream::binary); std::ofstream f(tmp_name.c_str(), std::fstream::binary);
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("unable to write ", tmp_name);
}
else
{
diskio::save_arma_binary(x, tmp_name, f);
const bool writing_problem = (f.good() == false); if(save_okay == true)
{
save_okay = diskio::save_arma_binary(x, f);
f.flush(); f.flush();
f.close(); f.close();
arma_warn( writing_problem, "trouble writing ", tmp_name ); if(save_okay == true)
if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
//! Save a matrix in binary format, //! Save a matrix in binary format,
//! with a header that stores the matrix type as well as its dimensions //! with a header that stores the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_binary(const Mat<eT>& x, const std::string& name, std::os diskio::save_arma_binary(const Mat<eT>& x, std::ostream& f)
tream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
f << diskio::gen_bin_header(x) << '\n'; f << diskio::gen_bin_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << '\n'; f << x.n_rows << ' ' << x.n_cols << '\n';
f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT)); f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
return f.good();
} }
//! Save a matrix as a PGM greyscale image //! Save a matrix as a PGM greyscale image
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_pgm_binary(const Mat<eT>& x, const std::string& final_name) diskio::save_pgm_binary(const Mat<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::fstream f(tmp_name.c_str(), std::fstream::out | std::fstream::binary ); std::fstream f(tmp_name.c_str(), std::fstream::out | std::fstream::binary );
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("unable to write ", tmp_name);
}
else
{
diskio::save_pgm_binary(x, tmp_name, f);
const bool writing_problem = (f.good() == false); if(save_okay == true)
{
arma_warn(writing_problem, "trouble writing ", tmp_name ); save_okay = diskio::save_pgm_binary(x, f);
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(save_okay == true)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
// //
// TODO: // TODO:
// add functionality to save the image in a normalised format, // add functionality to save the image in a normalised format,
// i.e. scaled so that every value falls in the [0,255] range. // i.e. scaled so that every value falls in the [0,255] range.
//! Save a matrix as a PGM greyscale image //! Save a matrix as a PGM greyscale image
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_pgm_binary(const Mat<eT>& x, const std::string& name, std::ost diskio::save_pgm_binary(const Mat<eT>& x, std::ostream& f)
ream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
f << "P5" << '\n'; f << "P5" << '\n';
f << x.n_cols << ' ' << x.n_rows << '\n'; f << x.n_cols << ' ' << x.n_rows << '\n';
f << 255 << '\n'; f << 255 << '\n';
const u32 n_elem = x.n_rows * x.n_cols; const u32 n_elem = x.n_rows * x.n_cols;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
u32 i = 0; u32 i = 0;
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
tmp[i] = u8( x(row,col) ); // TODO: add round() ? tmp[i] = u8( x.at(row,col) ); // TODO: add round() ?
++i; ++i;
} }
} }
f.write(reinterpret_cast<const char*>(tmp.mem), n_elem); f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
return f.good();
} }
//! Save a matrix as a PGM greyscale image //! Save a matrix as a PGM greyscale image
template<typename T> template<typename T>
inline inline
void bool
diskio::save_pgm_binary(const Mat< std::complex<T> >& x, const std::string& final_name) diskio::save_pgm_binary(const Mat< std::complex<T> >& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uchar_mat tmp = conv_to<uchar_mat>::from(x); const uchar_mat tmp = conv_to<uchar_mat>::from(x);
diskio::save_pgm_binary(tmp, final_name);
return diskio::save_pgm_binary(tmp, final_name);
} }
//! Save a matrix as a PGM greyscale image //! Save a matrix as a PGM greyscale image
template<typename T> template<typename T>
inline inline
void bool
diskio::save_pgm_binary(const Mat< std::complex<T> >& x, const std::string& diskio::save_pgm_binary(const Mat< std::complex<T> >& x, std::ostream& f)
name, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const uchar_mat tmp = conv_to<uchar_mat>::from(x); const uchar_mat tmp = conv_to<uchar_mat>::from(x);
diskio::save_pgm_binary(tmp, name, f);
return diskio::save_pgm_binary(tmp, f);
} }
//! Load a matrix as raw text (no header, human readable). //! Load a matrix as raw text (no header, human readable).
//! Can read matrices saved as text in Matlab and Octave. //! Can read matrices saved as text in Matlab and Octave.
//! NOTE: this is much slower than reading a file with a header. //! NOTE: this is much slower than reading a file with a header.
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_raw_ascii(Mat<eT>& x, const std::string& name) diskio::load_raw_ascii(Mat<eT>& x, const std::string& name, std::string& er
r_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in); f.open(name.c_str(), std::fstream::in);
if(f.is_open() == false) bool load_okay = f.is_open();
{
x.reset(); if(load_okay == true)
arma_extra_debug_print("unable to read ", name);
}
else
{ {
diskio::load_raw_ascii(x, name, f); load_okay = diskio::load_raw_ascii(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Load a matrix as raw text (no header, human readable). //! Load a matrix as raw text (no header, human readable).
//! Can read matrices saved as text in Matlab and Octave. //! Can read matrices saved as text in Matlab and Octave.
//! NOTE: this is much slower than reading a file with a header. //! NOTE: this is much slower than reading a file with a header.
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_raw_ascii(Mat<eT>& x, const std::string& name, std::istream& f diskio::load_raw_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg)
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
//std::fstream::pos_type start = f.tellg(); //std::fstream::pos_type start = f.tellg();
// //
// work out the size // work out the size
skipping to change at line 787 skipping to change at line 783
if(f_n_cols_found == false) if(f_n_cols_found == false)
{ {
f_n_cols = line_n_cols; f_n_cols = line_n_cols;
f_n_cols_found = true; f_n_cols_found = true;
} }
else else
{ {
if(line_n_cols != f_n_cols) if(line_n_cols != f_n_cols)
{ {
arma_print("inconsistent number of columns in ", name ); err_msg = "inconsistent number of columns in ";
load_okay = false; load_okay = false;
} }
} }
++f_n_rows; ++f_n_rows;
} }
if(load_okay == true) if(load_okay == true)
{ {
f.clear(); f.clear();
skipping to change at line 820 skipping to change at line 816
// x.at(row,col) = eT( strtod(token.c_str(), 0) ); // x.at(row,col) = eT( strtod(token.c_str(), 0) );
f >> val; f >> val;
x.at(row,col) = val; x.at(row,col) = val;
} }
} }
} }
if(f.good() == false) if(f.good() == false)
{ {
arma_print("trouble reading ", name );
load_okay = false; load_okay = false;
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
//! Load a matrix in text format (human readable), //! Load a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions //! with a header that indicates the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_ascii(Mat<eT>& x, const std::string& name) diskio::load_arma_ascii(Mat<eT>& x, const std::string& name, std::string& e
rr_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::ifstream f(name.c_str()); std::ifstream f(name.c_str());
if(f.is_open() == false)
{ bool load_okay = f.is_open();
x.reset();
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
}
else
{ {
diskio::load_arma_ascii(x, name, f); load_okay = diskio::load_arma_ascii(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Load a matrix in text format (human readable), //! Load a matrix in text format (human readable),
//! with a header that indicates the matrix type as well as its dimensions //! with a header that indicates the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_ascii(Mat<eT>& x, const std::string& name, std::istream& diskio::load_arma_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; u32 f_n_rows;
u32 f_n_cols; u32 f_n_cols;
f >> f_header; f >> f_header;
skipping to change at line 883 skipping to change at line 875
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f >> x.at(row,col); f >> x.at(row,col);
} }
} }
if(f.good() == false) load_okay = f.good();
{
arma_print("trouble reading ", name);
load_okay = false;
}
} }
else else
{ {
arma_print("incorrect header in ", name );
load_okay = false; load_okay = false;
err_msg = "incorrect header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
//! Load a matrix in binary format, //! Load a matrix in binary format,
//! with a header that indicates the matrix type as well as its dimensions //! with a header that indicates the matrix type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_binary(Mat<eT>& x, const std::string& name) diskio::load_arma_binary(Mat<eT>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::ifstream f; std::ifstream f;
f.open(name.c_str(), std::fstream::binary); f.open(name.c_str(), std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
x.reset(); if(load_okay == true)
arma_extra_debug_print("unable to read ", name);
}
else
{ {
diskio::load_arma_binary(x, name, f); load_okay = diskio::load_arma_binary(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_binary(Mat<eT>& x, const std::string& name, std::istream& diskio::load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; u32 f_n_rows;
u32 f_n_cols; u32 f_n_cols;
f >> f_header; f >> f_header;
skipping to change at line 950 skipping to change at line 934
f >> f_n_cols; f >> f_n_cols;
if(f_header == diskio::gen_bin_header(x)) if(f_header == diskio::gen_bin_header(x))
{ {
//f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters //f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters
f.get(); f.get();
x.set_size(f_n_rows,f_n_cols); x.set_size(f_n_rows,f_n_cols);
f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT)); f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT));
if(f.good() == false) load_okay = f.good();
{
arma_print("trouble reading ", name);
load_okay = false;
}
} }
else else
{ {
arma_print("incorrect header in ", name);
load_okay = false; load_okay = false;
err_msg = "incorrect header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
inline inline
void void
diskio::pnm_skip_comments(std::istream& f) diskio::pnm_skip_comments(std::istream& f)
{ {
while( isspace(f.peek()) ) while( isspace(f.peek()) )
{ {
while( isspace(f.peek()) ) while( isspace(f.peek()) )
{ {
skipping to change at line 992 skipping to change at line 969
{ {
f.get(); f.get();
} }
} }
} }
} }
//! Load a PGM greyscale image as a matrix //! Load a PGM greyscale image as a matrix
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_pgm_binary(Mat<eT>& x, const std::string& name) diskio::load_pgm_binary(Mat<eT>& x, const std::string& name, std::string& e
rr_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
x.reset();
}
else
{ {
diskio::load_pgm_binary(x, name, f); // Do the actual load load_okay = diskio::load_pgm_binary(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Load a PGM greyscale image as a matrix //! Load a PGM greyscale image as a matrix
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_pgm_binary(Mat<eT>& x, const std::string& name, std::istream& diskio::load_pgm_binary(Mat<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
f >> f_header; f >> f_header;
if(f_header == "P5") if(f_header == "P5")
{ {
u32 f_n_rows = 0; u32 f_n_rows = 0;
u32 f_n_cols = 0; u32 f_n_cols = 0;
skipping to change at line 1087 skipping to change at line 1063
for(u32 col=0; col < f_n_cols; ++col) for(u32 col=0; col < f_n_cols; ++col)
{ {
x.at(row,col) = eT(tmp[i]); x.at(row,col) = eT(tmp[i]);
++i; ++i;
} }
} }
} }
} }
else
{
load_okay = false;
err_msg = "currently no code available to handle loading ";
}
if(f.good() == false) if(f.good() == false)
{ {
arma_print("trouble reading ", name);
load_okay = false; load_okay = false;
} }
} }
else else
{ {
arma_print("unsupported header in ", name);
load_okay = false; load_okay = false;
err_msg = "unsupported header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
//! Load a PGM greyscale image as a matrix //! Load a PGM greyscale image as a matrix
template<typename T> template<typename T>
inline inline
void bool
diskio::load_pgm_binary(Mat< std::complex<T> >& x, const std::string& name) diskio::load_pgm_binary(Mat< std::complex<T> >& x, const std::string& name,
std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
uchar_mat tmp; uchar_mat tmp;
diskio::load_pgm_binary(tmp, name); const bool load_okay = diskio::load_pgm_binary(tmp, name, err_msg);
x = conv_to< Mat< std::complex<T> > >::from(tmp); x = conv_to< Mat< std::complex<T> > >::from(tmp);
return load_okay;
} }
//! Load a PGM greyscale image as a matrix //! Load a PGM greyscale image as a matrix
template<typename T> template<typename T>
inline inline
void bool
diskio::load_pgm_binary(Mat< std::complex<T> >& x, const std::string& name, diskio::load_pgm_binary(Mat< std::complex<T> >& x, std::istream& is, std::s
std::istream& is) tring& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
uchar_mat tmp; uchar_mat tmp;
diskio::load_pgm_binary(tmp, name, is); const bool load_okay = diskio::load_pgm_binary(tmp, is, err_msg);
x = conv_to< Mat< std::complex<T> > >::from(tmp); x = conv_to< Mat< std::complex<T> > >::from(tmp);
return load_okay;
} }
//! Try to load a matrix by automatically determining its type //! Try to load a matrix by automatically determining its type
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_auto_detect(Mat<eT>& x, const std::string& name) diskio::load_auto_detect(Mat<eT>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
x.reset();
}
else
{ {
diskio::load_auto_detect(x, name, f); // Do the actual load load_okay = diskio::load_auto_detect(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Try to load a matrix by automatically determining its type //! Try to load a matrix by automatically determining its type
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_auto_detect(Mat<eT>& x, const std::string& name, std::istream& diskio::load_auto_detect(Mat<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
static const std::string ARMA_MAT_TXT = "ARMA_MAT_TXT"; static const std::string ARMA_MAT_TXT = "ARMA_MAT_TXT";
static const std::string ARMA_MAT_BIN = "ARMA_MAT_BIN"; static const std::string ARMA_MAT_BIN = "ARMA_MAT_BIN";
static const std::string P5 = "P5"; static const std::string P5 = "P5";
podarray<char> raw_header(ARMA_MAT_TXT.length() + 1); podarray<char> raw_header(ARMA_MAT_TXT.length() + 1);
std::streampos pos = f.tellg(); std::streampos pos = f.tellg();
skipping to change at line 1181 skipping to change at line 1163
f.read(raw_header.memptr(), ARMA_MAT_TXT.length()); f.read(raw_header.memptr(), ARMA_MAT_TXT.length());
raw_header[ARMA_MAT_TXT.length()] = '\0'; raw_header[ARMA_MAT_TXT.length()] = '\0';
f.clear(); f.clear();
f.seekg(pos); f.seekg(pos);
const std::string header = raw_header.mem; const std::string header = raw_header.mem;
if(ARMA_MAT_TXT == header.substr(0,ARMA_MAT_TXT.length())) if(ARMA_MAT_TXT == header.substr(0,ARMA_MAT_TXT.length()))
{ {
load_arma_ascii(x, name, f); return load_arma_ascii(x, f, err_msg);
} }
else else
if(ARMA_MAT_BIN == header.substr(0,ARMA_MAT_BIN.length())) if(ARMA_MAT_BIN == header.substr(0,ARMA_MAT_BIN.length()))
{ {
load_arma_binary(x, name, f); return load_arma_binary(x, f, err_msg);
} }
else else
if(P5 == header.substr(0,P5.length())) if(P5 == header.substr(0,P5.length()))
{ {
load_pgm_binary(x, name, f); return load_pgm_binary(x, f, err_msg);
} }
else else
{ {
load_raw_ascii(x, name, f); return load_raw_ascii(x, f, err_msg);
} }
} }
// cubes // cubes
//! Save a cube as raw text (no header, human readable). //! Save a cube as raw text (no header, human readable).
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_raw_ascii(const Cube<eT>& x, const std::string& final_name) diskio::save_raw_ascii(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::fstream f(tmp_name.c_str(), std::fstream::out); std::fstream f(tmp_name.c_str(), std::fstream::out);
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("unable to write ", tmp_name);
}
else
{
save_raw_ascii(x, tmp_name, f);
const bool writing_problem = (f.good() == false);
arma_warn(writing_problem, "trouble writing ", tmp_name ); if(save_okay == true)
{
save_okay = save_raw_ascii(x, f);
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(save_okay == true)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
//! Save a cube as raw text (no header, human readable). //! Save a cube as raw text (no header, human readable).
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_raw_ascii(const Cube<eT>& x, const std::string& name, std::ost diskio::save_raw_ascii(const Cube<eT>& x, std::ostream& f)
ream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
u32 cell_width; u32 cell_width;
// TODO: need sane values for complex numbers // TODO: need sane values for complex numbers
if( (is_float<eT>::value == true) || (is_double<eT>::value == true) ) if( (is_float<eT>::value == true) || (is_double<eT>::value == true) )
{ {
f.setf(ios::scientific); f.setf(ios::scientific);
skipping to change at line 1273 skipping to change at line 1251
{ {
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col,slice); f << x.at(row,col,slice);
} }
f.put('\n'); f.put('\n');
} }
} }
return f.good();
} }
//! Save a cube in text format (human readable), //! Save a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions //! with a header that indicates the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_ascii(const Cube<eT>& x, const std::string& final_name) diskio::save_arma_ascii(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str()); std::ofstream f(tmp_name.c_str());
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_debug_print("unable to write ", tmp_name);
}
else
{
diskio::save_arma_ascii(x, tmp_name, f);
const bool writing_problem = (f.good() == false); if(save_okay == true)
{
save_okay = diskio::save_arma_ascii(x, f);
f.flush(); f.flush();
f.close(); f.close();
arma_warn( writing_problem, "trouble writing ", tmp_name ); if(save_okay == true)
if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
//! Save a cube in text format (human readable), //! Save a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions //! with a header that indicates the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_ascii(const Cube<eT>& x, const std::string& name, std::os diskio::save_arma_ascii(const Cube<eT>& x, std::ostream& f)
tream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const ios::fmtflags orig_flags = f.flags(); const ios::fmtflags orig_flags = f.flags();
f << diskio::gen_txt_header(x) << '\n'; f << diskio::gen_txt_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n'; f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
u32 cell_width; u32 cell_width;
skipping to change at line 1355 skipping to change at line 1331
f.width(cell_width); f.width(cell_width);
} }
f << x.at(row,col,slice); f << x.at(row,col,slice);
} }
f.put('\n'); f.put('\n');
} }
} }
const bool save_okay = f.good();
f.flags(orig_flags); f.flags(orig_flags);
return save_okay;
} }
//! Save a cube in binary format, //! Save a cube in binary format,
//! with a header that stores the cube type as well as its dimensions //! with a header that stores the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_binary(const Cube<eT>& x, const std::string& final_name) diskio::save_arma_binary(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f(tmp_name.c_str(), std::fstream::binary); std::ofstream f(tmp_name.c_str(), std::fstream::binary);
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("unable to write ", tmp_name);
}
else
{
diskio::save_arma_binary(x, tmp_name, f);
const bool writing_problem = (f.good() == false); if(save_okay == true)
{
save_okay = diskio::save_arma_binary(x, f);
f.flush(); f.flush();
f.close(); f.close();
arma_warn( writing_problem, "trouble writing ", tmp_name ); if(save_okay == true)
if(writing_problem == false)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
//! Save a cube in binary format, //! Save a cube in binary format,
//! with a header that stores the cube type as well as its dimensions //! with a header that stores the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_arma_binary(const Cube<eT>& x, const std::string& name, std::o diskio::save_arma_binary(const Cube<eT>& x, std::ostream& f)
stream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
f << diskio::gen_bin_header(x) << '\n'; f << diskio::gen_bin_header(x) << '\n';
f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n'; f << x.n_rows << ' ' << x.n_cols << ' ' << x.n_slices << '\n';
f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT)); f.write(reinterpret_cast<const char*>(x.mem), x.n_elem*sizeof(eT));
return f.good();
} }
//! Load a cube as raw text (no header, human readable). //! Load a cube as raw text (no header, human readable).
//! NOTE: this is much slower than reading a file with a header. //! NOTE: this is much slower than reading a file with a header.
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_raw_ascii(Cube<eT>& x, const std::string& name) diskio::load_raw_ascii(Cube<eT>& x, const std::string& name, std::string& e
rr_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
diskio::load_raw_ascii(tmp, name); const bool load_okay = diskio::load_raw_ascii(tmp, name, err_msg);
x.set_size(tmp.n_rows, tmp.n_cols, 1);
if(x.n_slices > 0) if(load_okay == true)
{ {
x.slice(0) = tmp; x.set_size(tmp.n_rows, tmp.n_cols, 1);
// make sure the loaded matrix was not empty
if(x.n_slices > 0)
{
x.slice(0) = tmp;
}
} }
return load_okay;
} }
//! Load a cube as raw text (no header, human readable). //! Load a cube as raw text (no header, human readable).
//! NOTE: this is much slower than reading a file with a header. //! NOTE: this is much slower than reading a file with a header.
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_raw_ascii(Cube<eT>& x, const std::string& name, std::istream& diskio::load_raw_ascii(Cube<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT> tmp; Mat<eT> tmp;
diskio::load_raw_ascii(tmp, name, f); const bool load_okay = diskio::load_raw_ascii(tmp, f, err_msg);
x.set_size(tmp.n_rows, tmp.n_cols, 1);
if(x.n_slices > 0) if(load_okay == true)
{ {
x.slice(0) = tmp; x.set_size(tmp.n_rows, tmp.n_cols, 1);
// make sure the loaded matrix was not empty
if(x.n_slices > 0)
{
x.slice(0) = tmp;
}
} }
return load_okay;
} }
//! Load a cube in text format (human readable), //! Load a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions //! with a header that indicates the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_ascii(Cube<eT>& x, const std::string& name) diskio::load_arma_ascii(Cube<eT>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::ifstream f(name.c_str()); std::ifstream f(name.c_str());
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
}
else
{ {
diskio::load_arma_ascii(x, name, f); load_okay = diskio::load_arma_ascii(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Load a cube in text format (human readable), //! Load a cube in text format (human readable),
//! with a header that indicates the cube type as well as its dimensions //! with a header that indicates the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_ascii(Cube<eT>& x, const std::string& name, std::istream& diskio::load_arma_ascii(Cube<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; u32 f_n_rows;
u32 f_n_cols; u32 f_n_cols;
u32 f_n_slices; u32 f_n_slices;
skipping to change at line 1505 skipping to change at line 1496
{ {
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
{ {
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f >> x.at(row,col,slice); f >> x.at(row,col,slice);
} }
} }
} }
if(f.good() == false) load_okay = f.good();
{
arma_print("trouble reading ", name);
load_okay = false;
}
} }
else else
{ {
arma_print("incorrect header in ", name );
load_okay = false; load_okay = false;
err_msg = "incorrect header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
//! Load a cube in binary format, //! Load a cube in binary format,
//! with a header that indicates the cube type as well as its dimensions //! with a header that indicates the cube type as well as its dimensions
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_binary(Cube<eT>& x, const std::string& name) diskio::load_arma_binary(Cube<eT>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::ifstream f; std::ifstream f;
f.open(name.c_str(), std::fstream::binary); f.open(name.c_str(), std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
}
else
{ {
diskio::load_arma_binary(x, name, f); load_okay = diskio::load_arma_binary(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_arma_binary(Cube<eT>& x, const std::string& name, std::istream diskio::load_arma_binary(Cube<eT>& x, std::istream& f, std::string& err_msg
& f) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
u32 f_n_rows; u32 f_n_rows;
u32 f_n_cols; u32 f_n_cols;
u32 f_n_slices; u32 f_n_slices;
skipping to change at line 1573 skipping to change at line 1557
f >> f_n_slices; f >> f_n_slices;
if(f_header == diskio::gen_bin_header(x)) if(f_header == diskio::gen_bin_header(x))
{ {
//f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters //f.seekg(1, ios::cur); // NOTE: this may not be portable, as on a Win dows machine a newline could be two characters
f.get(); f.get();
x.set_size(f_n_rows, f_n_cols, f_n_slices); x.set_size(f_n_rows, f_n_cols, f_n_slices);
f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT)); f.read( reinterpret_cast<char *>(x.memptr()), x.n_elem*sizeof(eT));
if(f.good() == false) load_okay = f.good();
{
arma_print("trouble reading ", name);
load_okay = false;
}
} }
else else
{ {
arma_print("incorrect header in ", name);
load_okay = false; load_okay = false;
err_msg = "incorrect header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
//! Try to load a cube by automatically determining its type //! Try to load a cube by automatically determining its type
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_auto_detect(Cube<eT>& x, const std::string& name) diskio::load_auto_detect(Cube<eT>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
x.reset();
}
else
{ {
diskio::load_auto_detect(x, name, f); // Do the actual load load_okay = diskio::load_auto_detect(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Try to load a cube by automatically determining its type //! Try to load a cube by automatically determining its type
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_auto_detect(Cube<eT>& x, const std::string& name, std::istream diskio::load_auto_detect(Cube<eT>& x, std::istream& f, std::string& err_msg
& f) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
static const std::string ARMA_CUB_TXT = "ARMA_CUB_TXT"; static const std::string ARMA_CUB_TXT = "ARMA_CUB_TXT";
static const std::string ARMA_CUB_BIN = "ARMA_CUB_BIN"; static const std::string ARMA_CUB_BIN = "ARMA_CUB_BIN";
static const std::string P6 = "P6"; static const std::string P6 = "P6";
podarray<char> raw_header(ARMA_CUB_TXT.length() + 1); podarray<char> raw_header(ARMA_CUB_TXT.length() + 1);
std::streampos pos = f.tellg(); std::streampos pos = f.tellg();
skipping to change at line 1640 skipping to change at line 1616
f.read(raw_header.memptr(), ARMA_CUB_TXT.length()); f.read(raw_header.memptr(), ARMA_CUB_TXT.length());
raw_header[ARMA_CUB_TXT.length()] = '\0'; raw_header[ARMA_CUB_TXT.length()] = '\0';
f.clear(); f.clear();
f.seekg(pos); f.seekg(pos);
const std::string header = raw_header.mem; const std::string header = raw_header.mem;
if(ARMA_CUB_TXT == header.substr(0, ARMA_CUB_TXT.length())) if(ARMA_CUB_TXT == header.substr(0, ARMA_CUB_TXT.length()))
{ {
load_arma_ascii(x, name, f); return load_arma_ascii(x, f, err_msg);
} }
else else
if(ARMA_CUB_BIN == header.substr(0, ARMA_CUB_BIN.length())) if(ARMA_CUB_BIN == header.substr(0, ARMA_CUB_BIN.length()))
{ {
load_arma_binary(x, name, f); return load_arma_binary(x, f, err_msg);
} }
else else
if(P6 == header.substr(0,P6.length())) if(P6 == header.substr(0, P6.length()))
{ {
load_ppm_binary(x, name, f); return load_ppm_binary(x, f, err_msg);
} }
else else
{ {
load_raw_ascii(x, name, f); return load_raw_ascii(x, f, err_msg);
} }
} }
// fields // fields
template<typename T1> template<typename T1>
inline inline
void bool
diskio::save_arma_binary(const field<T1>& x, const std::string& final_name) diskio::save_arma_binary(const field<T1>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) std::ofstream f( tmp_name.c_str(), std::fstream::binary );
{
arma_print("couldn't write ", tmp_name);
}
else
{
diskio::save_arma_binary(x, tmp_name, f);
const bool writing_problem = (f.good() == false); bool save_okay = f.is_open();
arma_warn(writing_problem, "trouble writing ", tmp_name ); if(save_okay == true)
{
save_okay = diskio::save_arma_binary(x, f);
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(save_okay == true)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
template<typename T1> template<typename T1>
inline inline
void bool
diskio::save_arma_binary(const field<T1>& x, const std::string& name, std:: diskio::save_arma_binary(const field<T1>& x, std::ostream& f)
ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f alse) >::apply(); arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f alse) >::apply();
f << "ARMA_FLD_BIN" << '\n'; f << "ARMA_FLD_BIN" << '\n';
f << x.n_rows << '\n'; f << x.n_rows << '\n';
f << x.n_cols << '\n'; f << x.n_cols << '\n';
bool save_okay = true;
for(u32 i=0; i<x.n_elem; ++i) for(u32 i=0; i<x.n_elem; ++i)
{ {
diskio::save_arma_binary(x[i], name, f); save_okay = diskio::save_arma_binary(x[i], f);
if(save_okay == false)
{
break;
}
} }
return save_okay;
} }
template<typename T1> template<typename T1>
inline inline
void bool
diskio::load_arma_binary(field<T1>& x, const std::string& name) diskio::load_arma_binary(field<T1>& x, const std::string& name, std::string
& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::ifstream f( name.c_str(), std::fstream::binary ); std::ifstream f( name.c_str(), std::fstream::binary );
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
}
else
{ {
diskio::load_arma_binary(x, name, f); load_okay = diskio::load_arma_binary(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
template<typename T1> template<typename T1>
inline inline
void bool
diskio::load_arma_binary(field<T1>& x, const std::string& name, std::istrea diskio::load_arma_binary(field<T1>& x, std::istream& f, std::string& err_ms
m& f) g)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f alse) >::apply(); arma_type_check< (is_Mat<T1>::value == false) && (is_Cube<T1>::value == f alse) >::apply();
bool load_okay = true; bool load_okay = true;
std::string f_type; std::string f_type;
f >> f_type; f >> f_type;
if(f_type != "ARMA_FLD_BIN") if(f_type != "ARMA_FLD_BIN")
{ {
arma_print("unsupported field type in ", name);
load_okay = false; load_okay = false;
err_msg = "unsupported field type in ";
} }
else else
{ {
u32 f_n_rows; u32 f_n_rows;
u32 f_n_cols; u32 f_n_cols;
f >> f_n_rows; f >> f_n_rows;
f >> f_n_cols; f >> f_n_cols;
x.set_size(f_n_rows, f_n_cols); x.set_size(f_n_rows, f_n_cols);
f.get(); f.get();
for(u32 i=0; i<x.n_elem; ++i) for(u32 i=0; i<x.n_elem; ++i)
{ {
diskio::load_arma_binary(x[i], name, f); load_okay = diskio::load_arma_binary(x[i], f, err_msg);
if(f.good() == false) if(load_okay == false)
{ {
arma_print("trouble reading ", name);
load_okay = false;
break; break;
} }
} }
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
inline inline
void bool
diskio::save_std_string(const field<std::string>& x, const std::string& fin al_name) diskio::save_std_string(const field<std::string>& x, const std::string& fin al_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary ); std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("couldn't write ", tmp_name);
}
else
{
diskio::save_std_string(x, tmp_name, f);
const bool writing_problem = (f.good() == false); if(save_okay == true)
{
save_okay = diskio::save_std_string(x, f);
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(save_okay == true)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
inline inline
void bool
diskio::save_std_string(const field<std::string>& x, const std::string& nam diskio::save_std_string(const field<std::string>& x, std::ostream& f)
e, std::ostream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
for(u32 row=0; row<x.n_rows; ++row) for(u32 row=0; row<x.n_rows; ++row)
for(u32 col=0; col<x.n_cols; ++col) for(u32 col=0; col<x.n_cols; ++col)
{ {
f << x.at(row,col); f << x.at(row,col);
if(col < x.n_cols-1) if(col < x.n_cols-1)
{ {
f << ' '; f << ' ';
} }
else else
{ {
f << '\n'; f << '\n';
} }
} }
const bool writing_problem = (f.good() == false); return f.good();
arma_warn(writing_problem, "trouble writing ", name );
} }
inline inline
void bool
diskio::load_std_string(field<std::string>& x, const std::string& name) diskio::load_std_string(field<std::string>& x, const std::string& name, std
::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::ifstream f( name.c_str() ); std::ifstream f( name.c_str() );
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_print("unable to read ", name);
}
else
{
diskio::load_std_string(x, name, f);
if(load_okay == true)
{
load_okay = diskio::load_std_string(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
inline inline
void bool
diskio::load_std_string(field<std::string>& x, const std::string& name, std diskio::load_std_string(field<std::string>& x, std::istream& f, std::string
::istream& f) & err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
// //
// work out the size // work out the size
u32 f_n_rows = 0; u32 f_n_rows = 0;
u32 f_n_cols = 0; u32 f_n_cols = 0;
skipping to change at line 1897 skipping to change at line 1870
if(f_n_cols_found == false) if(f_n_cols_found == false)
{ {
f_n_cols = line_n_cols; f_n_cols = line_n_cols;
f_n_cols_found = true; f_n_cols_found = true;
} }
else else
{ {
if(line_n_cols != f_n_cols) if(line_n_cols != f_n_cols)
{ {
load_okay = false; load_okay = false;
arma_print("inconsistent number of columns in ", name ); err_msg = "inconsistent number of columns in ";
} }
} }
++f_n_rows; ++f_n_rows;
} }
if(load_okay == true) if(load_okay == true)
{ {
f.clear(); f.clear();
f.seekg(0, ios::beg); f.seekg(0, ios::beg);
skipping to change at line 1924 skipping to change at line 1897
for(u32 col=0; col < x.n_cols; ++col) for(u32 col=0; col < x.n_cols; ++col)
{ {
f >> x.at(row,col); f >> x.at(row,col);
} }
} }
} }
if(f.good() == false) if(f.good() == false)
{ {
load_okay = false; load_okay = false;
arma_print("trouble reading ", name );
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
//! Try to load a field by automatically determining its type //! Try to load a field by automatically determining its type
template<typename T1> template<typename T1>
inline inline
void bool
diskio::load_auto_detect(field<T1>& x, const std::string& name) diskio::load_auto_detect(field<T1>& x, const std::string& name, std::string
& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
x.reset();
}
else
{ {
diskio::load_auto_detect(x, name, f); // Do the actual load load_okay = diskio::load_auto_detect(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
//! Try to load a field by automatically determining its type //! Try to load a field by automatically determining its type
template<typename T1> template<typename T1>
inline inline
void bool
diskio::load_auto_detect(field<T1>& x, const std::string& name, std::istrea diskio::load_auto_detect(field<T1>& x, std::istream& f, std::string& err_ms
m& f) g)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check<is_Mat<T1>::value == false>::apply();
static const std::string ARMA_FLD_BIN = "ARMA_FLD_BIN"; static const std::string ARMA_FLD_BIN = "ARMA_FLD_BIN";
static const std::string P6 = "P6"; static const std::string P6 = "P6";
podarray<char> raw_header(ARMA_FLD_BIN.length() + 1); podarray<char> raw_header(ARMA_FLD_BIN.length() + 1);
skipping to change at line 1982 skipping to change at line 1950
f.read(raw_header.memptr(), ARMA_FLD_BIN.length()); f.read(raw_header.memptr(), ARMA_FLD_BIN.length());
f.clear(); f.clear();
f.seekg(pos); f.seekg(pos);
raw_header[ARMA_FLD_BIN.length()] = '\0'; raw_header[ARMA_FLD_BIN.length()] = '\0';
const std::string header = raw_header.mem; const std::string header = raw_header.mem;
if(ARMA_FLD_BIN == header.substr(0,ARMA_FLD_BIN.length())) if(ARMA_FLD_BIN == header.substr(0, ARMA_FLD_BIN.length()))
{ {
load_arma_binary(x, name, f); return load_arma_binary(x, f, err_msg);
} }
else else
if(P6 == header.substr(0,P6.length())) if(P6 == header.substr(0, P6.length()))
{ {
load_ppm_binary(x, name, f); return load_ppm_binary(x, f, err_msg);
} }
else else
{ {
arma_print("unsupported header in ", name); err_msg = "unsupported header in ";
x.reset(); return false;
} }
} }
// //
// handling of PPM images // handling of PPM images by cubes
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_ppm_binary(Cube<eT>& x, const std::string& name) diskio::load_ppm_binary(Cube<eT>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
}
else
{ {
diskio::load_ppm_binary(x, name, f); load_okay = diskio::load_ppm_binary(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
template<typename eT> template<typename eT>
inline inline
void bool
diskio::load_ppm_binary(Cube<eT>& x, const std::string& name, std::istream& diskio::load_ppm_binary(Cube<eT>& x, std::istream& f, std::string& err_msg)
f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
f >> f_header; f >> f_header;
if(f_header == "P6") if(f_header == "P6")
{ {
skipping to change at line 2103 skipping to change at line 2071
x.at(row,col,1) = eT(tmp[i+1]); x.at(row,col,1) = eT(tmp[i+1]);
x.at(row,col,2) = eT(tmp[i+2]); x.at(row,col,2) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
} }
else
{
load_okay = false;
err_msg = "currently no code available to handle loading ";
}
if(f.good() == false) if(f.good() == false)
{ {
arma_print("trouble reading ", name);
load_okay = false; load_okay = false;
} }
} }
else else
{ {
arma_print("unsupported header in ", name);
load_okay = false; load_okay = false;
err_msg = "unsupported header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_ppm_binary(const Cube<eT>& x, const std::string& final_name) diskio::save_ppm_binary(const Cube<eT>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary ); std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("couldn't write ", tmp_name); if(save_okay == true)
}
else
{ {
diskio::save_ppm_binary(x, tmp_name, f); save_okay = diskio::save_ppm_binary(x, f);
const bool writing_problem = (f.good() == false);
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(save_okay == true)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
template<typename eT> template<typename eT>
inline inline
void bool
diskio::save_ppm_binary(const Cube<eT>& x, const std::string& name, std::os diskio::save_ppm_binary(const Cube<eT>& x, std::ostream& f)
tream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (x.n_slices != 3), "diskio::save_ppm_binary(): given cu be must have exactly 3 slices" ); arma_debug_check( (x.n_slices != 3), "diskio::save_ppm_binary(): given cu be must have exactly 3 slices" );
const u32 n_elem = 3 * x.n_rows * x.n_cols; const u32 n_elem = 3 * x.n_rows * x.n_cols;
podarray<u8> tmp(n_elem); podarray<u8> tmp(n_elem);
u32 i = 0; u32 i = 0;
for(u32 row=0; row < x.n_rows; ++row) for(u32 row=0; row < x.n_rows; ++row)
skipping to change at line 2184 skipping to change at line 2153
} }
} }
f << "P6" << '\n'; f << "P6" << '\n';
f << x.n_cols << '\n'; f << x.n_cols << '\n';
f << x.n_rows << '\n'; f << x.n_rows << '\n';
f << 255 << '\n'; f << 255 << '\n';
f.write(reinterpret_cast<const char*>(tmp.mem), n_elem); f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
const bool writing_problem = (f.good() == false); return f.good();
arma_warn(writing_problem, "trouble writing ", name );
} }
//
// handling of PPM images by fields
template<typename T1> template<typename T1>
inline inline
void bool
diskio::load_ppm_binary(field<T1>& x, const std::string& name) diskio::load_ppm_binary(field<T1>& x, const std::string& name, std::string&
err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
std::fstream f; std::fstream f;
f.open(name.c_str(), std::fstream::in | std::fstream::binary); f.open(name.c_str(), std::fstream::in | std::fstream::binary);
if(f.is_open() == false) bool load_okay = f.is_open();
{
arma_extra_debug_print("unable to read ", name); if(load_okay == true)
}
else
{ {
diskio::load_ppm_binary(x, name, f); load_okay = diskio::load_ppm_binary(x, f, err_msg);
f.close(); f.close();
} }
return load_okay;
} }
template<typename T1> template<typename T1>
inline inline
void bool
diskio::load_ppm_binary(field<T1>& x, const std::string& name, std::istream diskio::load_ppm_binary(field<T1>& x, std::istream& f, std::string& err_msg
& f) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check<is_Mat<T1>::value == false>::apply();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
bool load_okay = true; bool load_okay = true;
std::string f_header; std::string f_header;
f >> f_header; f >> f_header;
skipping to change at line 2301 skipping to change at line 2271
G.at(row,col) = eT(tmp[i+1]); G.at(row,col) = eT(tmp[i+1]);
B.at(row,col) = eT(tmp[i+2]); B.at(row,col) = eT(tmp[i+2]);
i+=3; i+=3;
} }
} }
} }
} }
else
{
load_okay = false;
err_msg = "currently no code available to handle loading ";
}
if(f.good() == false) if(f.good() == false)
{ {
arma_print("trouble reading ", name);
load_okay = false; load_okay = false;
} }
} }
else else
{ {
arma_print("unsupported header in ", name);
load_okay = false; load_okay = false;
err_msg = "unsupported header in ";
} }
if(load_okay == false) return load_okay;
{
x.reset();
}
} }
template<typename T1> template<typename T1>
inline inline
void bool
diskio::save_ppm_binary(const field<T1>& x, const std::string& final_name) diskio::save_ppm_binary(const field<T1>& x, const std::string& final_name)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const std::string tmp_name = diskio::gen_tmp_name(final_name); const std::string tmp_name = diskio::gen_tmp_name(final_name);
std::ofstream f( tmp_name.c_str(), std::fstream::binary ); std::ofstream f( tmp_name.c_str(), std::fstream::binary );
if(f.is_open() == false) bool save_okay = f.is_open();
{
arma_print("couldn't write ", tmp_name); if(save_okay == true)
}
else
{ {
diskio::save_ppm_binary(x, tmp_name, f); save_okay = diskio::save_ppm_binary(x, f);
const bool writing_problem = (f.good() == false);
f.flush(); f.flush();
f.close(); f.close();
if(writing_problem == false) if(save_okay == true)
{ {
diskio::safe_rename(tmp_name, final_name); save_okay = diskio::safe_rename(tmp_name, final_name);
} }
} }
return save_okay;
} }
template<typename T1> template<typename T1>
inline inline
void bool
diskio::save_ppm_binary(const field<T1>& x, const std::string& name, std::o diskio::save_ppm_binary(const field<T1>& x, std::ostream& f)
stream& f)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<T1>::value == false>::apply(); arma_type_check<is_Mat<T1>::value == false>::apply();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check( (x.n_elem != 3), "diskio::save_ppm_binary(): given fiel d must have exactly 3 matrices of equal size" ); arma_debug_check( (x.n_elem != 3), "diskio::save_ppm_binary(): given fiel d must have exactly 3 matrices of equal size" );
bool same_size = true; bool same_size = true;
skipping to change at line 2403 skipping to change at line 2372
tmp[i+0] = u8( access::tmp_real( R.at(row,col) ) ); tmp[i+0] = u8( access::tmp_real( R.at(row,col) ) );
tmp[i+1] = u8( access::tmp_real( G.at(row,col) ) ); tmp[i+1] = u8( access::tmp_real( G.at(row,col) ) );
tmp[i+2] = u8( access::tmp_real( B.at(row,col) ) ); tmp[i+2] = u8( access::tmp_real( B.at(row,col) ) );
i+=3; i+=3;
} }
} }
f.write(reinterpret_cast<const char*>(tmp.mem), n_elem); f.write(reinterpret_cast<const char*>(tmp.mem), n_elem);
const bool writing_problem = (f.good() == false); return f.good();
arma_warn(writing_problem, "trouble writing ", name );
} }
//! @} //! @}
 End of changes. 248 change blocks. 
459 lines changed or deleted 421 lines changed or added


 diskio_proto.hpp   diskio_proto.hpp 
skipping to change at line 55 skipping to change at line 55
template<typename eT> inline static std::string gen_bin_header(const Mat< eT>& x); template<typename eT> inline static std::string gen_bin_header(const Mat< eT>& x);
template<typename eT> inline static std::string gen_txt_header(const Cube <eT>& x); template<typename eT> inline static std::string gen_txt_header(const Cube <eT>& x);
template<typename eT> inline static std::string gen_bin_header(const Cube <eT>& x); template<typename eT> inline static std::string gen_bin_header(const Cube <eT>& x);
inline static char conv_to_hex_char(const u8 x); inline static char conv_to_hex_char(const u8 x);
inline static void conv_to_hex(char* out, const u8 x); inline static void conv_to_hex(char* out, const u8 x);
inline static std::string gen_tmp_name(const std::string& x); inline static std::string gen_tmp_name(const std::string& x);
inline static void safe_rename(const std::string& old_name, const std::st ring& new_name); inline static bool safe_rename(const std::string& old_name, const std::st ring& new_name);
// //
// matrix saving // matrix saving
template<typename eT> inline static void save_raw_ascii (const Mat<eT>& template<typename eT> inline static bool save_raw_ascii (const Mat<eT>&
x, const std::string& final_name); x, const std::string& final_name);
template<typename eT> inline static void save_raw_ascii (const Mat<eT>& template<typename eT> inline static bool save_arma_ascii (const Mat<eT>&
x, const std::string& name, std::ostream& f); x, const std::string& final_name);
template<typename eT> inline static void save_arma_ascii (const Mat<eT>& template<typename eT> inline static bool save_arma_binary(const Mat<eT>&
x, const std::string& final_name); x, const std::string& final_name);
template<typename eT> inline static void save_arma_ascii (const Mat<eT>& template<typename eT> inline static bool save_pgm_binary (const Mat<eT>&
x, const std::string& name, std::ostream& f); x, const std::string& final_name);
template<typename eT> inline static void save_arma_binary(const Mat<eT>& template<typename T> inline static bool save_pgm_binary (const Mat< std:
x, const std::string& final_name); :complex<T> >& x, const std::string& final_name);
template<typename eT> inline static void save_arma_binary(const Mat<eT>&
x, const std::string& name, std::ostream& f); template<typename eT> inline static bool save_raw_ascii (const Mat<eT>&
template<typename eT> inline static void save_pgm_binary (const Mat<eT>& x, std::ostream& f);
x, const std::string& final_nname); template<typename eT> inline static bool save_arma_ascii (const Mat<eT>&
template<typename eT> inline static void save_pgm_binary (const Mat<eT>& x, std::ostream& f);
x, const std::string& name, std::ostream& f); template<typename eT> inline static bool save_arma_binary(const Mat<eT>&
template<typename T> inline static void save_pgm_binary (const Mat< std: x, std::ostream& f);
:complex<T> >& x, const std::string& final_name); template<typename eT> inline static bool save_pgm_binary (const Mat<eT>&
template<typename T> inline static void save_pgm_binary (const Mat< std: x, std::ostream& f);
:complex<T> >& x, const std::string& name, std::ostream& f); template<typename T> inline static bool save_pgm_binary (const Mat< std:
:complex<T> >& x, std::ostream& f);
// //
// matrix loading // matrix loading
template<typename eT> inline static void load_raw_ascii (Mat<eT>& x, con template<typename eT> inline static bool load_raw_ascii (Mat<eT>&
st std::string& name); x, const std::string& name, std::string& err_msg);
template<typename eT> inline static void load_raw_ascii (Mat<eT>& x, con template<typename eT> inline static bool load_arma_ascii (Mat<eT>&
st std::string& name, std::istream& f); x, const std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con template<typename eT> inline static bool load_arma_binary(Mat<eT>&
st std::string& name); x, const std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_ascii (Mat<eT>& x, con template<typename eT> inline static bool load_pgm_binary (Mat<eT>&
st std::string& name, std::istream& f); x, const std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con template<typename T> inline static bool load_pgm_binary (Mat< std::compl
st std::string& name); ex<T> >& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_binary(Mat<eT>& x, con template<typename eT> inline static bool load_auto_detect(Mat<eT>&
st std::string& name, std::istream& f); x, const std::string& name, std::string& err_msg);
template<typename eT> inline static void load_pgm_binary (Mat<eT>& x, con
st std::string& name); template<typename eT> inline static bool load_raw_ascii (Mat<eT>&
template<typename eT> inline static void load_pgm_binary (Mat<eT>& x, con x, std::istream& f, std::string& err_msg);
st std::string& name, std::istream& is); template<typename eT> inline static bool load_arma_ascii (Mat<eT>&
template<typename T> inline static void load_pgm_binary (Mat< std::compl x, std::istream& f, std::string& err_msg);
ex<T> >& x, const std::string& name); template<typename eT> inline static bool load_arma_binary(Mat<eT>&
template<typename T> inline static void load_pgm_binary (Mat< std::compl x, std::istream& f, std::string& err_msg);
ex<T> >& x, const std::string& name, std::istream& is); template<typename eT> inline static bool load_pgm_binary (Mat<eT>&
template<typename eT> inline static void load_auto_detect(Mat<eT>& x, con x, std::istream& is, std::string& err_msg);
st std::string& name); template<typename T> inline static bool load_pgm_binary (Mat< std::compl
template<typename eT> inline static void load_auto_detect(Mat<eT>& x, con ex<T> >& x, std::istream& is, std::string& err_msg);
st std::string& name, std::istream& f); template<typename eT> inline static bool load_auto_detect(Mat<eT>&
x, std::istream& f, std::string& err_msg);
inline static void pnm_skip_comments(std::istream& f); inline static void pnm_skip_comments(std::istream& f);
// //
// cube saving // cube saving
template<typename eT> inline static void save_raw_ascii (const Cube<eT>& template<typename eT> inline static bool save_raw_ascii (const Cube<eT>&
x, const std::string& name); x, const std::string& name);
template<typename eT> inline static void save_raw_ascii (const Cube<eT>& template<typename eT> inline static bool save_arma_ascii (const Cube<eT>&
x, const std::string& name, std::ostream& f); x, const std::string& name);
template<typename eT> inline static void save_arma_ascii (const Cube<eT>& template<typename eT> inline static bool save_arma_binary(const Cube<eT>&
x, const std::string& name); x, const std::string& name);
template<typename eT> inline static void save_arma_ascii (const Cube<eT>&
x, const std::string& name, std::ostream& f); template<typename eT> inline static bool save_raw_ascii (const Cube<eT>&
template<typename eT> inline static void save_arma_binary(const Cube<eT>& x, std::ostream& f);
x, const std::string& name); template<typename eT> inline static bool save_arma_ascii (const Cube<eT>&
template<typename eT> inline static void save_arma_binary(const Cube<eT>& x, std::ostream& f);
x, const std::string& name, std::ostream& f); template<typename eT> inline static bool save_arma_binary(const Cube<eT>&
x, std::ostream& f);
// //
// cube loading // cube loading
template<typename eT> inline static void load_raw_ascii (Cube<eT>& x, co template<typename eT> inline static bool load_raw_ascii (Cube<eT>& x, co
nst std::string& name); nst std::string& name, std::string& err_msg);
template<typename eT> inline static void load_raw_ascii (Cube<eT>& x, co template<typename eT> inline static bool load_arma_ascii (Cube<eT>& x, co
nst std::string& name, std::istream& f); nst std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_ascii (Cube<eT>& x, co template<typename eT> inline static bool load_arma_binary(Cube<eT>& x, co
nst std::string& name); nst std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_ascii (Cube<eT>& x, co template<typename eT> inline static bool load_auto_detect(Cube<eT>& x, co
nst std::string& name, std::istream& f); nst std::string& name, std::string& err_msg);
template<typename eT> inline static void load_arma_binary(Cube<eT>& x, co
nst std::string& name); template<typename eT> inline static bool load_raw_ascii (Cube<eT>& x, st
template<typename eT> inline static void load_arma_binary(Cube<eT>& x, co d::istream& f, std::string& err_msg);
nst std::string& name, std::istream& f); template<typename eT> inline static bool load_arma_ascii (Cube<eT>& x, st
template<typename eT> inline static void load_auto_detect(Cube<eT>& x, co d::istream& f, std::string& err_msg);
nst std::string& name); template<typename eT> inline static bool load_arma_binary(Cube<eT>& x, st
template<typename eT> inline static void load_auto_detect(Cube<eT>& x, co d::istream& f, std::string& err_msg);
nst std::string& name, std::istream& f); template<typename eT> inline static bool load_auto_detect(Cube<eT>& x, st
d::istream& f, std::string& err_msg);
// //
// field saving and loading // field saving and loading
template<typename T1> inline static void save_arma_binary(const field<T1> template<typename T1> inline static bool save_arma_binary(const field<T1>
& x, const std::string& name); & x, const std::string& name);
template<typename T1> inline static void save_arma_binary(const field<T1> template<typename T1> inline static bool save_arma_binary(const field<T1>
& x, const std::string& name, std::ostream& f); & x, std::ostream& f);
template<typename T1> inline static void load_arma_binary( field<T1>
& x, const std::string& name); template<typename T1> inline static bool load_arma_binary( field<T1>
template<typename T1> inline static void load_arma_binary( field<T1> & x, const std::string& name, std::string& err_msg);
& x, const std::string& name, std::istream& f); template<typename T1> inline static bool load_arma_binary( field<T1>
& x, std::istream& f, std::string& err_msg);
inline static void save_std_string(const field<std::string>& x, const std
::string& name); template<typename T1> inline static bool load_auto_detect( field<T1>
inline static void save_std_string(const field<std::string>& x, const std & x, const std::string& name, std::string& err_msg);
::string& name, std::ostream& f); template<typename T1> inline static bool load_auto_detect( field<T1>
inline static void load_std_string( field<std::string>& x, const std & x, std::istream& f, std::string& err_msg);
::string& name);
inline static void load_std_string( field<std::string>& x, const std inline static bool save_std_string(const field<std::string>& x, const std
::string& name, std::istream& f); ::string& name);
inline static bool save_std_string(const field<std::string>& x, std
template<typename T1> inline static void load_auto_detect(field<T1>& x, c ::ostream& f);
onst std::string& name);
template<typename T1> inline static void load_auto_detect(field<T1>& x, c inline static bool load_std_string( field<std::string>& x, const std
onst std::string& name, std::istream& f); ::string& name, std::string& err_msg);
inline static bool load_std_string( field<std::string>& x, std
// ::istream& f, std::string& err_msg);
// PPM images
//
template<typename T1> inline static void save_ppm_binary(const Cube<T1>& // handling of PPM images by cubes
x, const std::string& final_name);
template<typename T1> inline static void save_ppm_binary(const Cube<T1>& template<typename T1> inline static bool save_ppm_binary(const Cube<T1>&
x, const std::string& name, std::ostream& f); x, const std::string& final_name);
template<typename T1> inline static void load_ppm_binary( Cube<T1>& template<typename T1> inline static bool save_ppm_binary(const Cube<T1>&
x, const std::string& final_name); x, std::ostream& f);
template<typename T1> inline static void load_ppm_binary( Cube<T1>&
x, const std::string& name, std::istream& f); template<typename T1> inline static bool load_ppm_binary( Cube<T1>&
x, const std::string& final_name, std::string& err_msg);
template<typename T1> inline static void save_ppm_binary(const field<T1>& template<typename T1> inline static bool load_ppm_binary( Cube<T1>&
x, const std::string& final_name); x, std::istream& f, std::string& err_msg);
template<typename T1> inline static void save_ppm_binary(const field<T1>&
x, const std::string& final_name, std::ostream& f); //
template<typename T1> inline static void load_ppm_binary( field<T1>& // handling of PPM images by fields
x, const std::string& final_name);
template<typename T1> inline static void load_ppm_binary( field<T1>& template<typename T1> inline static bool save_ppm_binary(const field<T1>&
x, const std::string& final_name, std::istream& f); x, const std::string& final_name);
template<typename T1> inline static bool save_ppm_binary(const field<T1>&
x, std::ostream& f);
template<typename T1> inline static bool load_ppm_binary( field<T1>&
x, const std::string& final_name, std::string& err_msg);
template<typename T1> inline static bool load_ppm_binary( field<T1>&
x, std::istream& f, std::string& err_msg);
}; };
//! @} //! @}
 End of changes. 6 change blocks. 
116 lines changed or deleted 127 lines changed or added


 eop_aux.hpp   eop_aux.hpp 
skipping to change at line 20 skipping to change at line 20
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup eop_aux //! \addtogroup eop_aux
//! @{ //! @{
template<typename eT> template<typename eT>
struct eop_aux_rand struct eop_aux_randu
{ {
arma_inline arma_inline
operator eT () operator eT ()
{ {
return eT(std::rand()) / eT(RAND_MAX); return eT(std::rand()) / eT(RAND_MAX);
} }
}; };
template<typename T> template<typename T>
struct eop_aux_rand< std::complex<T> > struct eop_aux_randu< std::complex<T> >
{ {
arma_inline arma_inline
operator std::complex<T> () operator std::complex<T> ()
{ {
return std::complex<T>( T(eop_aux_rand<T>()), T(eop_aux_rand<T>()) ); return std::complex<T>( T(eop_aux_randu<T>()), T(eop_aux_randu<T>()) );
} }
}; };
template<typename eT> template<typename eT>
struct eop_aux_randn struct eop_aux_randn
{ {
// // rudimentary method, based on the central limit theorem // // rudimentary method, based on the central limit theorem
// // http://en.wikipedia.org/wiki/Central_limit_theorem // // http://en.wikipedia.org/wiki/Central_limit_theorem
// inline // inline
// operator eT () const // operator eT () const
skipping to change at line 114 skipping to change at line 114
}; };
//! use of the SFINAE approach to work around compiler limitations //! use of the SFINAE approach to work around compiler limitations
//! http://en.wikipedia.org/wiki/SFINAE //! http://en.wikipedia.org/wiki/SFINAE
class eop_aux class eop_aux
{ {
public: public:
#if defined(ARMA_USE_BOOST) template<typename eT> arma_inline static typename arma_integral_only<eT>:
#define arma_boost_wrap(trig_fn, val) ( (boost::math::trig_fn)(val) ) :result acos (const eT& x) { return std::acos(double(x)); }
#else template<typename eT> arma_inline static typename arma_integral_only<eT>:
#define arma_boost_wrap(trig_fn, val) ( arma_stop( #trig_fn "(): need B :result asin (const eT& x) { return std::asin(double(x)); }
oost libraries" ), val ) template<typename eT> arma_inline static typename arma_integral_only<eT>:
#endif :result atan (const eT& x) { return std::atan(double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: template<typename eT> arma_inline static typename arma_float_only<eT>::re
:result acos (const eT& x) { return std::acos(double(x)); } sult acos (const eT& x) { return std::acos(x); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: template<typename eT> arma_inline static typename arma_float_only<eT>::re
:result asin (const eT& x) { return std::asin(double(x)); } sult asin (const eT& x) { return std::asin(x); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: template<typename eT> arma_inline static typename arma_float_only<eT>::re
:result atan (const eT& x) { return std::atan(double(x)); } sult atan (const eT& x) { return std::atan(x); }
template<typename eT> arma_inline static typename arma_float_only<eT>::re template<typename eT> arma_inline static typename arma_cx_only<eT>::resul
sult acos (const eT& x) { return std::acos(x); } t acos (const eT& x) { return arma_acos(x); }
template<typename eT> arma_inline static typename arma_float_only<eT>::re template<typename eT> arma_inline static typename arma_cx_only<eT>::resul
sult asin (const eT& x) { return std::asin(x); } t asin (const eT& x) { return arma_asin(x); }
template<typename eT> arma_inline static typename arma_float_only<eT>::re template<typename eT> arma_inline static typename arma_cx_only<eT>::resul
sult atan (const eT& x) { return std::atan(x); } t atan (const eT& x) { return arma_atan(x); }
template<typename T> arma_inline static std::complex<T> acos (const std: template<typename eT> arma_inline static typename arma_integral_only<eT>:
:complex<T>& x) { return arma_boost_wrap(acos, x); } :result acosh (const eT& x) { return arma_acosh(double(x)); }
template<typename T> arma_inline static std::complex<T> asin (const std: template<typename eT> arma_inline static typename arma_integral_only<eT>:
:complex<T>& x) { return arma_boost_wrap(asin, x); } :result asinh (const eT& x) { return arma_asinh(double(x)); }
template<typename T> arma_inline static std::complex<T> atan (const std: template<typename eT> arma_inline static typename arma_integral_only<eT>:
:complex<T>& x) { return arma_boost_wrap(atan, x); } :result atanh (const eT& x) { return arma_atanh(double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: template<typename eT> arma_inline static typename arma_float_or_cx_only<e
:result acosh (const eT& x) { return arma_boost_wrap(acosh, double(x)); } T>::result acosh (const eT& x) { return arma_acosh(x); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: template<typename eT> arma_inline static typename arma_float_or_cx_only<e
:result asinh (const eT& x) { return arma_boost_wrap(asinh, double(x)); } T>::result asinh (const eT& x) { return arma_asinh(x); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: template<typename eT> arma_inline static typename arma_float_or_cx_only<e
:result atanh (const eT& x) { return arma_boost_wrap(atanh, double(x)); } T>::result atanh (const eT& x) { return arma_atanh(x); }
template<typename eT> arma_inline static typename arma_float_only<eT>::re
sult acosh (const eT& x) { return arma_boost_wrap(acosh, x); }
template<typename eT> arma_inline static typename arma_float_only<eT>::re
sult asinh (const eT& x) { return arma_boost_wrap(asinh, x); }
template<typename eT> arma_inline static typename arma_float_only<eT>::re
sult atanh (const eT& x) { return arma_boost_wrap(atanh, x); }
template<typename T> arma_inline static std::complex<T> acosh (const std
::complex<T>& x) { return arma_boost_wrap(acosh, x); }
template<typename T> arma_inline static std::complex<T> asinh (const std
::complex<T>& x) { return arma_boost_wrap(asinh, x); }
template<typename T> arma_inline static std::complex<T> atanh (const std
::complex<T>& x) { return arma_boost_wrap(atanh, x); }
#undef arma_boost_wrap
template<typename eT> arma_inline static eT conj(const eT& x) { return x; } template<typename eT> arma_inline static eT conj(const eT& x) { return x; }
template<typename T> arma_inline static std::complex<T> conj(const std:: complex<T>& x) { return std::conj(x); } template<typename T> arma_inline static std::complex<T> conj(const std:: complex<T>& x) { return std::conj(x); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result sqrt (const eT& x) { return std::sqrt (double(x)); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result sqrt (const eT& x) { return std::sqrt (double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result log10 (const eT& x) { return std::log10(double(x)); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result log10 (const eT& x) { return std::log10(double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result log (const eT& x) { return std::log (double(x)); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result log (const eT& x) { return std::log (double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result exp (const eT& x) { return std::exp (double(x)); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result exp (const eT& x) { return std::exp (double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result cos (const eT& x) { return std::cos (double(x)); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result cos (const eT& x) { return std::cos (double(x)); }
template<typename eT> arma_inline static typename arma_integral_only<eT>: :result sin (const eT& x) { return std::sin (double(x)); } template<typename eT> arma_inline static typename arma_integral_only<eT>: :result sin (const eT& x) { return std::sin (double(x)); }
skipping to change at line 171 skipping to change at line 159
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result log10 (const eT& x) { return std::log10(x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result log10 (const eT& x) { return std::log10(x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result log (const eT& x) { return std::log (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result log (const eT& x) { return std::log (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result exp (const eT& x) { return std::exp (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result exp (const eT& x) { return std::exp (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result cos (const eT& x) { return std::cos (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result cos (const eT& x) { return std::cos (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result sin (const eT& x) { return std::sin (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result sin (const eT& x) { return std::sin (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result tan (const eT& x) { return std::tan (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result tan (const eT& x) { return std::tan (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result cosh (const eT& x) { return std::cosh (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result cosh (const eT& x) { return std::cosh (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result sinh (const eT& x) { return std::sinh (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result sinh (const eT& x) { return std::sinh (x); }
template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result tanh (const eT& x) { return std::tanh (x); } template<typename eT> arma_inline static typename arma_float_or_cx_only<e T>::result tanh (const eT& x) { return std::tanh (x); }
template<typename T1, typename T2> arma_inline static template<typename T1, typename T2>
T1 pow(const T1 base, const T2 exponent) { return std::pow(base, ex arma_inline
ponent); }
template<typename T2> arma_inline static
char pow(const char base, const T2 exponent) { typedef char out_t; ret
urn out_t( std::pow(double(base), double(exponent) ) ); }
template<typename T2> arma_inline static
short pow(const short base, const T2 exponent) { typedef short out_t; ret
urn out_t( std::pow(double(base), double(exponent) ) ); }
template<typename T2> arma_inline static
int pow(const int base, const T2 exponent) { typedef int out_t; ret
urn out_t( std::pow(double(base), double(exponent) ) ); }
template<typename T2> arma_inline static
long pow(const long base, const T2 exponent) { typedef long out_t; ret
urn out_t( std::pow(double(base), double(exponent) ) ); }
template<typename T2> arma_inline static
unsigned char pow(const unsigned char base, const T2 exponent) { typede
f unsigned char out_t; return out_t( std::pow(double(base), double(exponen
t) ) ); }
template<typename T2> arma_inline static
unsigned short pow(const unsigned short base, const T2 exponent) { typede
f unsigned short out_t; return out_t( std::pow(double(base), double(exponen
t) ) ); }
template<typename T2> arma_inline static
unsigned int pow(const unsigned int base, const T2 exponent) { typede
f unsigned int out_t; return out_t( std::pow(double(base), double(exponen
t) ) ); }
template<typename T2> arma_inline static
unsigned long pow(const unsigned long base, const T2 exponent) { typede
f unsigned long out_t; return out_t( std::pow(double(base), double(exponen
t) ) ); }
template<typename T1> arma_inline static
T1 pow_int(const T1 base, const int exponent) { return std::pow(bas
e, exponent); }
arma_inline static
char pow_int(const char base, const int exponent) { typedef char out_t
; return out_t( std::pow(double(base), exponent) ); }
arma_inline static
short pow_int(const short base, const int exponent) { typedef short out_t
; return out_t( std::pow(double(base), exponent) ); }
arma_inline static
int pow_int(const int base, const int exponent) { typedef int out_t
; return out_t( std::pow(double(base), exponent) ); }
arma_inline static
long pow_int(const long base, const int exponent) { typedef long out_t
; return out_t( std::pow(double(base), exponent) ); }
arma_inline static
unsigned char pow_int(const unsigned char base, const int exponent) { t
ypedef unsigned char out_t; return out_t( std::pow(double(base), exponent)
); }
arma_inline static
unsigned short pow_int(const unsigned short base, const int exponent) { t
ypedef unsigned short out_t; return out_t( std::pow(double(base), exponent)
); }
arma_inline static
unsigned int pow_int(const unsigned int base, const int exponent) { t
ypedef unsigned int out_t; return out_t( std::pow(double(base), exponent)
); }
arma_inline static
unsigned long pow_int(const unsigned long base, const int exponent) { t
ypedef unsigned long out_t; return out_t( std::pow(double(base), exponent)
); }
template<typename eT>
inline
static static
eT typename arma_float_or_cx_only<T1>::result
trunc_exp(const eT x) pow(const T1 base, const T2 exponent)
{ {
if(std::numeric_limits<eT>::is_iec559 && (x >= Math<eT>::log_max() )) return std::pow(base, exponent);
{
return std::numeric_limits<eT>::max();
}
else
{
return std::exp(x);
}
} }
template<typename T> template<typename T1, typename T2>
inline arma_inline
static static
std::complex<T> typename arma_integral_only<T1>::result
trunc_exp(const std::complex<T>& x) pow(const T1 base, const T2 exponent)
{ {
return std::exp(x); return T1( std::pow( double(base), double(exponent) ) );
} }
template<typename eT> template<typename T1>
inline arma_inline
static static
eT typename arma_float_or_cx_only<T1>::result
trunc_log(const eT x) pow_int(const T1 base, const int exponent)
{ {
if(std::numeric_limits<eT>::is_iec559) return std::pow(base, exponent);
{
if(x == std::numeric_limits<eT>::infinity())
{
return Math<eT>::log_max();
}
else
if(x <= eT(0))
{
return Math<eT>::log_min();
}
else
{
return std::log(x);
}
}
else
{
return std::log(x);
}
} }
template<typename T> template<typename T1>
inline arma_inline
static static
std::complex<T> typename arma_integral_only<T1>::result
trunc_log(const std::complex<T>& x) pow_int(const T1 base, const int exponent)
{ {
return std::log(x); return T1( std::pow( double(base), exponent) );
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
static static
typename arma_integral_only<eT>::result typename arma_integral_only<eT>::result
direct_eps(const eT& x) direct_eps(const eT& x)
{ {
return eT(0); return eT(0);
} }
skipping to change at line 352 skipping to change at line 260
template<typename T> arma_inline static template<typename T> arma_inline static
typename arma_float_only<T>::result arma_abs(const std::comp lex<T>& x) { return std::abs(x); } typename arma_float_only<T>::result arma_abs(const std::comp lex<T>& x) { return std::abs(x); }
template<typename eT, typename eop_type> template<typename eT, typename eop_type>
arma_inline arma_inline
static static
eT eT
generate() generate()
{ {
if(is_same_type<eop_type, eop_rand >::value == true) { re turn eT(eop_aux_rand<eT>()); } if(is_same_type<eop_type, eop_randu >::value == true) { re turn eT(eop_aux_randu<eT>()); }
else if(is_same_type<eop_type, eop_randn >::value == true) { re turn eT(eop_aux_randn<eT>()); } else if(is_same_type<eop_type, eop_randn >::value == true) { re turn eT(eop_aux_randn<eT>()); }
else if(is_same_type<eop_type, eop_zeros >::value == true) { re turn eT(0); } else if(is_same_type<eop_type, eop_zeros >::value == true) { re turn eT(0); }
else if(is_same_type<eop_type, eop_ones_full >::value == true) { re turn eT(1); } else if(is_same_type<eop_type, eop_ones_full >::value == true) { re turn eT(1); }
else if(is_same_type<eop_type, eop_cube_rand >::value == true) { re turn eT(eop_aux_rand<eT>()); } else if(is_same_type<eop_type, eop_cube_randu >::value == true) { re turn eT(eop_aux_randu<eT>()); }
else if(is_same_type<eop_type, eop_cube_randn >::value == true) { re turn eT(eop_aux_randn<eT>()); } else if(is_same_type<eop_type, eop_cube_randn >::value == true) { re turn eT(eop_aux_randn<eT>()); }
else if(is_same_type<eop_type, eop_cube_zeros >::value == true) { re turn eT(0); } else if(is_same_type<eop_type, eop_cube_zeros >::value == true) { re turn eT(0); }
else if(is_same_type<eop_type, eop_cube_ones_full>::value == true) { re turn eT(1); } else if(is_same_type<eop_type, eop_cube_ones_full>::value == true) { re turn eT(1); }
else { re turn eT(0); } else { re turn eT(0); }
} }
}; };
//! @} //! @}
 End of changes. 18 change blocks. 
181 lines changed or deleted 59 lines changed or added


 eop_core_meat.hpp   eop_core_meat.hpp 
skipping to change at line 69 skipping to change at line 69
else if(is_same_type<eop_type, eop_scalar_plus >::value == true) { r eturn val + x.aux; } else if(is_same_type<eop_type, eop_scalar_plus >::value == true) { r eturn val + x.aux; }
else if(is_same_type<eop_type, eop_scalar_minus_pre >::value == true) { r eturn x.aux - val; } else if(is_same_type<eop_type, eop_scalar_minus_pre >::value == true) { r eturn x.aux - val; }
else if(is_same_type<eop_type, eop_scalar_minus_post>::value == true) { r eturn val - x.aux; } else if(is_same_type<eop_type, eop_scalar_minus_post>::value == true) { r eturn val - x.aux; }
else if(is_same_type<eop_type, eop_scalar_times >::value == true) { r eturn val * x.aux; } else if(is_same_type<eop_type, eop_scalar_times >::value == true) { r eturn val * x.aux; }
else if(is_same_type<eop_type, eop_scalar_div_pre >::value == true) { r eturn x.aux / val; } else if(is_same_type<eop_type, eop_scalar_div_pre >::value == true) { r eturn x.aux / val; }
else if(is_same_type<eop_type, eop_scalar_div_post >::value == true) { r eturn val / x.aux; } else if(is_same_type<eop_type, eop_scalar_div_post >::value == true) { r eturn val / x.aux; }
else if(is_same_type<eop_type, eop_square >::value == true) { r eturn val*val; } else if(is_same_type<eop_type, eop_square >::value == true) { r eturn val*val; }
else if(is_same_type<eop_type, eop_sqrt >::value == true) { r eturn eop_aux::sqrt(val); } else if(is_same_type<eop_type, eop_sqrt >::value == true) { r eturn eop_aux::sqrt(val); }
else if(is_same_type<eop_type, eop_log10 >::value == true) { r eturn eop_aux::log10(val); } else if(is_same_type<eop_type, eop_log10 >::value == true) { r eturn eop_aux::log10(val); }
else if(is_same_type<eop_type, eop_log >::value == true) { r eturn eop_aux::log(val); } else if(is_same_type<eop_type, eop_log >::value == true) { r eturn eop_aux::log(val); }
else if(is_same_type<eop_type, eop_trunc_log >::value == true) { r eturn eop_aux::trunc_log(val); } else if(is_same_type<eop_type, eop_trunc_log >::value == true) { r eturn arma::trunc_log(val); }
else if(is_same_type<eop_type, eop_exp >::value == true) { r eturn eop_aux::exp(val); } else if(is_same_type<eop_type, eop_exp >::value == true) { r eturn eop_aux::exp(val); }
else if(is_same_type<eop_type, eop_trunc_exp >::value == true) { r eturn eop_aux::trunc_exp(val); } else if(is_same_type<eop_type, eop_trunc_exp >::value == true) { r eturn arma::trunc_exp(val); }
else if(is_same_type<eop_type, eop_cos >::value == true) { r eturn eop_aux::cos(val); } else if(is_same_type<eop_type, eop_cos >::value == true) { r eturn eop_aux::cos(val); }
else if(is_same_type<eop_type, eop_sin >::value == true) { r eturn eop_aux::sin(val); } else if(is_same_type<eop_type, eop_sin >::value == true) { r eturn eop_aux::sin(val); }
else if(is_same_type<eop_type, eop_tan >::value == true) { r eturn eop_aux::tan(val); } else if(is_same_type<eop_type, eop_tan >::value == true) { r eturn eop_aux::tan(val); }
else if(is_same_type<eop_type, eop_acos >::value == true) { r eturn eop_aux::acos(val); } else if(is_same_type<eop_type, eop_acos >::value == true) { r eturn eop_aux::acos(val); }
else if(is_same_type<eop_type, eop_asin >::value == true) { r eturn eop_aux::asin(val); } else if(is_same_type<eop_type, eop_asin >::value == true) { r eturn eop_aux::asin(val); }
else if(is_same_type<eop_type, eop_atan >::value == true) { r eturn eop_aux::atan(val); } else if(is_same_type<eop_type, eop_atan >::value == true) { r eturn eop_aux::atan(val); }
else if(is_same_type<eop_type, eop_cosh >::value == true) { r eturn eop_aux::cosh(val); } else if(is_same_type<eop_type, eop_cosh >::value == true) { r eturn eop_aux::cosh(val); }
else if(is_same_type<eop_type, eop_sinh >::value == true) { r eturn eop_aux::sinh(val); } else if(is_same_type<eop_type, eop_sinh >::value == true) { r eturn eop_aux::sinh(val); }
else if(is_same_type<eop_type, eop_tanh >::value == true) { r eturn eop_aux::tanh(val); } else if(is_same_type<eop_type, eop_tanh >::value == true) { r eturn eop_aux::tanh(val); }
else if(is_same_type<eop_type, eop_acosh >::value == true) { r eturn eop_aux::acosh(val); } else if(is_same_type<eop_type, eop_acosh >::value == true) { r eturn eop_aux::acosh(val); }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 eop_core_proto.hpp   eop_core_proto.hpp 
skipping to change at line 87 skipping to change at line 87
class eop_ones_diag : public eop_core<eop_ones_diag> class eop_ones_diag : public eop_core<eop_ones_diag>
{ {
public: public:
arma_inline static const char* error_msg() { return "eye(): given size is not square"; } arma_inline static const char* error_msg() { return "eye(): given size is not square"; }
arma_inline static const bool size_ok(const u32 n_rows, const u32 n_cols) { return (n_rows == n_cols); } arma_inline static const bool size_ok(const u32 n_rows, const u32 n_cols) { return (n_rows == n_cols); }
}; };
class eop_ones_full : public eop_core<eop_ones_full>{}; class eop_ones_full : public eop_core<eop_ones_full>{};
class eop_rand : public eop_core<eop_rand> {}; class eop_randu : public eop_core<eop_randu> {};
class eop_randn : public eop_core<eop_randn> {}; class eop_randn : public eop_core<eop_randn> {};
class eop_zeros : public eop_core<eop_zeros> {}; class eop_zeros : public eop_core<eop_zeros> {};
template<typename T1> struct is_generator { static const boo l value = false; }; template<typename T1> struct is_generator { static const boo l value = false; };
template<> struct is_generator<eop_ones_full> { static const boo l value = true; }; template<> struct is_generator<eop_ones_full> { static const boo l value = true; };
template<> struct is_generator<eop_rand> { static const boo l value = true; }; template<> struct is_generator<eop_randu> { static const boo l value = true; };
template<> struct is_generator<eop_randn> { static const boo l value = true; }; template<> struct is_generator<eop_randn> { static const boo l value = true; };
template<> struct is_generator<eop_zeros> { static const boo l value = true; }; template<> struct is_generator<eop_zeros> { static const boo l value = true; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 eop_cube_core_meat.hpp   eop_cube_core_meat.hpp 
skipping to change at line 64 skipping to change at line 64
// the optimiser will keep only one return statement // the optimiser will keep only one return statement
if(is_same_type<eop_cube_type, eop_cube_neg >::value == true) { return -val; } if(is_same_type<eop_cube_type, eop_cube_neg >::value == true) { return -val; }
else if(is_same_type<eop_cube_type, eop_cube_scalar_plus >::value == true) { return val + x.aux; } else if(is_same_type<eop_cube_type, eop_cube_scalar_plus >::value == true) { return val + x.aux; }
else if(is_same_type<eop_cube_type, eop_cube_scalar_minus_pre >::value == true) { return x.aux - val; } else if(is_same_type<eop_cube_type, eop_cube_scalar_minus_pre >::value == true) { return x.aux - val; }
else if(is_same_type<eop_cube_type, eop_cube_scalar_minus_post>::value == true) { return val - x.aux; } else if(is_same_type<eop_cube_type, eop_cube_scalar_minus_post>::value == true) { return val - x.aux; }
else if(is_same_type<eop_cube_type, eop_cube_scalar_times >::value == true) { return val * x.aux; } else if(is_same_type<eop_cube_type, eop_cube_scalar_times >::value == true) { return val * x.aux; }
else if(is_same_type<eop_cube_type, eop_cube_scalar_div_pre >::value == true) { return x.aux / val; } else if(is_same_type<eop_cube_type, eop_cube_scalar_div_pre >::value == true) { return x.aux / val; }
else if(is_same_type<eop_cube_type, eop_cube_scalar_div_post >::value == true) { return val / x.aux; } else if(is_same_type<eop_cube_type, eop_cube_scalar_div_post >::value == true) { return val / x.aux; }
else if(is_same_type<eop_cube_type, eop_cube_square >::value == true) { return val*val; } else if(is_same_type<eop_cube_type, eop_cube_square >::value == true) { return val*val; }
else if(is_same_type<eop_cube_type, eop_cube_sqrt >::value == else if(is_same_type<eop_cube_type, eop_cube_sqrt >::value ==
true) { return std::sqrt(val); } true) { return eop_aux::sqrt(val); }
else if(is_same_type<eop_cube_type, eop_cube_log10 >::value == else if(is_same_type<eop_cube_type, eop_cube_log10 >::value ==
true) { return std::log10(val); } true) { return eop_aux::log10(val); }
else if(is_same_type<eop_cube_type, eop_cube_log >::value == else if(is_same_type<eop_cube_type, eop_cube_log >::value ==
true) { return std::log(val); } true) { return eop_aux::log(val); }
else if(is_same_type<eop_cube_type, eop_cube_trunc_log >::value == else if(is_same_type<eop_cube_type, eop_cube_trunc_log >::value ==
true) { return eop_aux::trunc_log(val); } true) { return arma::trunc_log(val); }
else if(is_same_type<eop_cube_type, eop_cube_exp >::value == else if(is_same_type<eop_cube_type, eop_cube_exp >::value ==
true) { return std::exp(val); } true) { return eop_aux::exp(val); }
else if(is_same_type<eop_cube_type, eop_cube_trunc_exp >::value == else if(is_same_type<eop_cube_type, eop_cube_trunc_exp >::value ==
true) { return eop_aux::trunc_exp(val); } true) { return arma::trunc_exp(val); }
else if(is_same_type<eop_cube_type, eop_cube_cos >::value == else if(is_same_type<eop_cube_type, eop_cube_cos >::value ==
true) { return std::cos(val); } true) { return eop_aux::cos(val); }
else if(is_same_type<eop_cube_type, eop_cube_cosh >::value == else if(is_same_type<eop_cube_type, eop_cube_cosh >::value ==
true) { return std::cosh(val); } true) { return eop_aux::cosh(val); }
else if(is_same_type<eop_cube_type, eop_cube_acos >::value == true) { return eop_aux::acos(val); } else if(is_same_type<eop_cube_type, eop_cube_acos >::value == true) { return eop_aux::acos(val); }
else if(is_same_type<eop_cube_type, eop_cube_acosh >::value == true) { return eop_aux::acosh(val); } else if(is_same_type<eop_cube_type, eop_cube_acosh >::value == true) { return eop_aux::acosh(val); }
else if(is_same_type<eop_cube_type, eop_cube_sin >::value == else if(is_same_type<eop_cube_type, eop_cube_sin >::value ==
true) { return std::sin(val); } true) { return eop_aux::sin(val); }
else if(is_same_type<eop_cube_type, eop_cube_sinh >::value == else if(is_same_type<eop_cube_type, eop_cube_sinh >::value ==
true) { return std::sinh(val); } true) { return eop_aux::sinh(val); }
else if(is_same_type<eop_cube_type, eop_cube_asin >::value == true) { return eop_aux::asin(val); } else if(is_same_type<eop_cube_type, eop_cube_asin >::value == true) { return eop_aux::asin(val); }
else if(is_same_type<eop_cube_type, eop_cube_asinh >::value == true) { return eop_aux::asinh(val); } else if(is_same_type<eop_cube_type, eop_cube_asinh >::value == true) { return eop_aux::asinh(val); }
else if(is_same_type<eop_cube_type, eop_cube_tan >::value == else if(is_same_type<eop_cube_type, eop_cube_tan >::value ==
true) { return std::tan(val); } true) { return eop_aux::tan(val); }
else if(is_same_type<eop_cube_type, eop_cube_tanh >::value == else if(is_same_type<eop_cube_type, eop_cube_tanh >::value ==
true) { return std::tanh(val); } true) { return eop_aux::tanh(val); }
else if(is_same_type<eop_cube_type, eop_cube_atan >::value == true) { return eop_aux::atan(val); } else if(is_same_type<eop_cube_type, eop_cube_atan >::value == true) { return eop_aux::atan(val); }
else if(is_same_type<eop_cube_type, eop_cube_atanh >::value == true) { return eop_aux::atanh(val); } else if(is_same_type<eop_cube_type, eop_cube_atanh >::value == true) { return eop_aux::atanh(val); }
else if(is_same_type<eop_cube_type, eop_cube_eps >::value == true) { return eop_aux::direct_eps(val);} else if(is_same_type<eop_cube_type, eop_cube_eps >::value == true) { return eop_aux::direct_eps(val);}
else if(is_same_type<eop_cube_type, eop_cube_abs >::value == true) { return eop_aux::arma_abs(val); } else if(is_same_type<eop_cube_type, eop_cube_abs >::value == true) { return eop_aux::arma_abs(val); }
else if(is_same_type<eop_cube_type, eop_cube_conj >::value == true) { return eop_aux::conj(val); } else if(is_same_type<eop_cube_type, eop_cube_conj >::value == true) { return eop_aux::conj(val); }
else if(is_same_type<eop_cube_type, eop_cube_pow >::value == true) { return eop_aux::pow(val, x.aux);} else if(is_same_type<eop_cube_type, eop_cube_pow >::value == true) { return eop_aux::pow(val, x.aux);}
else if(is_same_type<eop_cube_type, eop_cube_pow_int >::value == true) else if(is_same_type<eop_cube_type, eop_cube_pow_int >::value == true)
{ {
const int exponent = (x.aux_u32_b == 0) ? int(x.aux_u32_a) : -int(x.aux _u32_a); const int exponent = (x.aux_u32_b == 0) ? int(x.aux_u32_a) : -int(x.aux _u32_a);
 End of changes. 3 change blocks. 
24 lines changed or deleted 24 lines changed or added


 eop_cube_core_proto.hpp   eop_cube_core_proto.hpp 
skipping to change at line 74 skipping to change at line 74
class eop_cube_tanh : public eop_cube_core<eop_cube_tanh> {}; class eop_cube_tanh : public eop_cube_core<eop_cube_tanh> {};
class eop_cube_atan : public eop_cube_core<eop_cube_atan> {}; class eop_cube_atan : public eop_cube_core<eop_cube_atan> {};
class eop_cube_atanh : public eop_cube_core<eop_cube_atanh> {}; class eop_cube_atanh : public eop_cube_core<eop_cube_atanh> {};
class eop_cube_eps : public eop_cube_core<eop_cube_eps> {}; class eop_cube_eps : public eop_cube_core<eop_cube_eps> {};
class eop_cube_abs : public eop_cube_core<eop_cube_abs> {}; class eop_cube_abs : public eop_cube_core<eop_cube_abs> {};
class eop_cube_conj : public eop_cube_core<eop_cube_conj> {}; class eop_cube_conj : public eop_cube_core<eop_cube_conj> {};
class eop_cube_pow : public eop_cube_core<eop_cube_pow> {}; class eop_cube_pow : public eop_cube_core<eop_cube_pow> {};
class eop_cube_pow_int : public eop_cube_core<eop_cube_pow_int> {}; class eop_cube_pow_int : public eop_cube_core<eop_cube_pow_int> {};
class eop_cube_ones_full : public eop_cube_core<eop_cube_ones_full> {}; class eop_cube_ones_full : public eop_cube_core<eop_cube_ones_full> {};
class eop_cube_rand : public eop_cube_core<eop_cube_rand> {}; class eop_cube_randu : public eop_cube_core<eop_cube_randu> {};
class eop_cube_randn : public eop_cube_core<eop_cube_randn> {}; class eop_cube_randn : public eop_cube_core<eop_cube_randn> {};
class eop_cube_zeros : public eop_cube_core<eop_cube_zeros> {}; class eop_cube_zeros : public eop_cube_core<eop_cube_zeros> {};
template<typename T1> struct is_cube_generator { static const bool value = false; }; template<typename T1> struct is_cube_generator { static const bool value = false; };
template<> struct is_cube_generator<eop_cube_ones_full> { static const bool value = true; }; template<> struct is_cube_generator<eop_cube_ones_full> { static const bool value = true; };
template<> struct is_cube_generator<eop_cube_rand> { static const bool value = true; }; template<> struct is_cube_generator<eop_cube_randu> { static const bool value = true; };
template<> struct is_cube_generator<eop_cube_randn> { static const bool value = true; }; template<> struct is_cube_generator<eop_cube_randn> { static const bool value = true; };
template<> struct is_cube_generator<eop_cube_zeros> { static const bool value = true; }; template<> struct is_cube_generator<eop_cube_zeros> { static const bool value = true; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 field_meat.hpp   field_meat.hpp 
skipping to change at line 490 skipping to change at line 490
void void
field<oT>::reset_objects() field<oT>::reset_objects()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field_aux::reset_objects(*this); field_aux::reset_objects(*this);
} }
template<typename oT> template<typename oT>
inline inline
void bool
field<oT>::save(const std::string name, const file_type type) const field<oT>::save(const std::string name, const file_type type, const bool pr
int_status) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field_aux::save(*this, name, type); std::string err_msg;
const bool save_okay = field_aux::save(*this, name, type, err_msg);
if( (print_status == true) && (save_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("field::save(): ", err_msg, name);
}
else
{
arma_print("field::save(): couldn't write to ", name);
}
}
return save_okay;
} }
template<typename oT> template<typename oT>
inline inline
void bool
field<oT>::save(std::ostream& os, const file_type type) const field<oT>::save(std::ostream& os, const file_type type, const bool print_st
atus) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field_aux::save(*this, os, type); std::string err_msg;
const bool save_okay = field_aux::save(*this, os, type, err_msg);
if( (print_status == true) && (save_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("field::save(): ", err_msg, "[ostream]");
}
else
{
arma_print("field::save(): couldn't write to [ostream]");
}
}
return save_okay;
} }
template<typename oT> template<typename oT>
inline inline
void bool
field<oT>::load(const std::string name, const file_type type) field<oT>::load(const std::string name, const file_type type, const bool pr
int_status)
{
arma_extra_debug_sigprint();
std::string err_msg;
const bool load_okay = field_aux::load(*this, name, type, err_msg);
if( (print_status == true) && (load_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("field::load(): ", err_msg, name);
}
else
{
arma_print("field::load(): couldn't read from ", name);
}
}
if(load_okay == false)
{
(*this).reset();
}
return load_okay;
}
template<typename oT>
inline
bool
field<oT>::load(std::istream& is, const file_type type, const bool print_st
atus)
{
arma_extra_debug_sigprint();
std::string err_msg;
const bool load_okay = field_aux::load(*this, is, type, err_msg);
if( (print_status == true) && (load_okay == false) )
{
if(err_msg.length() > 0)
{
arma_print("field::load(): ", err_msg, "[istream]");
}
else
{
arma_print("field::load(): couldn't read from [istream]");
}
}
if(load_okay == false)
{
(*this).reset();
}
return load_okay;
}
template<typename oT>
inline
bool
field<oT>::quiet_save(const std::string name, const file_type type) const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field_aux::load(*this, name, type); return (*this).save(name, type, false);
} }
template<typename oT> template<typename oT>
inline inline
void bool
field<oT>::load(std::istream& is, const file_type type) field<oT>::quiet_save(std::ostream& os, const file_type type) const
{
arma_extra_debug_sigprint();
return (*this).save(os, type, false);
}
template<typename oT>
inline
bool
field<oT>::quiet_load(const std::string name, const file_type type)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
field_aux::load(*this, is, type); return (*this).load(name, type, false);
}
template<typename oT>
inline
bool
field<oT>::quiet_load(std::istream& is, const file_type type)
{
arma_extra_debug_sigprint();
return (*this).load(is, type, false);
} }
//! construct a field from a given field //! construct a field from a given field
template<typename oT> template<typename oT>
inline inline
void void
field<oT>::init(const field<oT>& x) field<oT>::init(const field<oT>& x)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 916 skipping to change at line 1026
(*(x.mem[i])).clear(); (*(x.mem[i])).clear();
} }
} }
// //
// //
// //
template<typename oT> template<typename oT>
inline inline
void bool
field_aux::save(const field<oT>& x, const std::string& name, const file_typ field_aux::save(const field<oT>& x, const std::string& name, const file_typ
e type) e type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_print("field_aux::save(): sorry, saving this type of field is curren err_msg = " [sorry, saving/loading this type of field is currently not su
tly not supported"); pported] filename = ";
return false;
} }
template<typename oT> template<typename oT>
inline inline
void bool
field_aux::save(const field<oT>& x, std::ostream& os, const file_type type) field_aux::save(const field<oT>& x, std::ostream& os, const file_type type,
std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_print("field_aux::save(): sorry, saving this type of field is curren err_msg = " [sorry, saving/loading this type of field is currently not su
tly not supported"); pported] filename = ";
return false;
} }
template<typename oT> template<typename oT>
inline inline
void bool
field_aux::load(field<oT>& x, const std::string& name, const file_type type field_aux::load(field<oT>& x, const std::string& name, const file_type type
) , std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_print("field_aux::load(): sorry, loading this type of field is curre err_msg = " [sorry, saving/loading this type of field is currently not su
ntly not supported"); pported] filename = ";
x.reset();
return false;
} }
template<typename oT> template<typename oT>
inline inline
void bool
field_aux::load(field<oT>& x, std::istream& is, const file_type type) field_aux::load(field<oT>& x, std::istream& is, const file_type type, std::
string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_print("field_aux::load(): sorry, loading this type of field is curre err_msg = " [sorry, saving/loading this type of field is currently not su
ntly not supported"); pported] filename = ";
x.reset();
return false;
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Mat<eT> >& x, const std::string& name, const f field_aux::save(const field< Mat<eT> >& x, const std::string& name, const f
ile_type type) ile_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, name); return diskio::save_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, name); return diskio::save_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Mat<eT> >& x, std::ostream& os, const file_typ field_aux::save(const field< Mat<eT> >& x, std::ostream& os, const file_typ
e type) e type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, "[ostream]", os); return diskio::save_arma_binary(x, os);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, "[ostream]", os); return diskio::save_ppm_binary(x, os);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Mat<eT> >& x, const std::string& name, const file_ty field_aux::load(field< Mat<eT> >& x, const std::string& name, const file_ty
pe type) pe type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, name); return diskio::load_auto_detect(x, name, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, name); return diskio::load_arma_binary(x, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, name); return diskio::load_ppm_binary(x, name, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Mat<eT> >& x, std::istream& is, const file_type type field_aux::load(field< Mat<eT> >& x, std::istream& is, const file_type type
) , std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, "[istream]", is); return diskio::load_auto_detect(x, is, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, "[istream]", is); return diskio::load_arma_binary(x, is, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, "[istream]", is); return diskio::load_ppm_binary(x, is, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Col<eT> >& x, const std::string& name, const f field_aux::save(const field< Col<eT> >& x, const std::string& name, const f
ile_type type) ile_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, name); return diskio::save_arma_binary(x, name);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, name); return diskio::save_ppm_binary(x, name);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Col<eT> >& x, std::ostream& os, const file_typ field_aux::save(const field< Col<eT> >& x, std::ostream& os, const file_typ
e type) e type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, "[ostream]", os); return diskio::save_arma_binary(x, os);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, "[ostream]", os); return diskio::save_ppm_binary(x, os);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Col<eT> >& x, const std::string& name, const file_ty field_aux::load(field< Col<eT> >& x, const std::string& name, const file_ty
pe type) pe type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, name); return diskio::load_auto_detect(x, name, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, name); return diskio::load_arma_binary(x, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, name); return diskio::load_ppm_binary(x, name, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Col<eT> >& x, std::istream& is, const file_type type field_aux::load(field< Col<eT> >& x, std::istream& is, const file_type type
) , std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, "[istream]", is); return diskio::load_auto_detect(x, is, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, "[istream]", is); return diskio::load_arma_binary(x, is, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, "[istream]", is); return diskio::load_ppm_binary(x, is, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Row<eT> >& x, const std::string& name, const f field_aux::save(const field< Row<eT> >& x, const std::string& name, const f
ile_type type) ile_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, name); return diskio::save_arma_binary(x, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, name); return diskio::save_ppm_binary(x, name, err_msg);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Row<eT> >& x, std::ostream& os, const file_typ field_aux::save(const field< Row<eT> >& x, std::ostream& os, const file_typ
e type) e type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, "[ostream]", os); return diskio::save_arma_binary(x, os, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, "[ostream]", os); return diskio::save_ppm_binary(x, os, err_msg);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Row<eT> >& x, const std::string& name, const file_ty field_aux::load(field< Row<eT> >& x, const std::string& name, const file_ty
pe type) pe type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, name); return diskio::load_auto_detect(x, name, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, name); return diskio::load_arma_binary(x, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, name); return diskio::load_ppm_binary(x, name, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Row<eT> >& x, std::istream& is, const file_type type field_aux::load(field< Row<eT> >& x, std::istream& is, const file_type type
) , std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, "[istream]", is); return diskio::load_auto_detect(x, is, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, "[istream]", is); return diskio::load_arma_binary(x, is, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, "[istream]", is); return diskio::load_ppm_binary(x, is, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Cube<eT> >& x, const std::string& name, const field_aux::save(const field< Cube<eT> >& x, const std::string& name, const
file_type type) file_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, name); return diskio::save_arma_binary(x, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, name); return diskio::save_ppm_binary(x, name, err_msg);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::save(const field< Cube<eT> >& x, std::ostream& os, const file_ty field_aux::save(const field< Cube<eT> >& x, std::ostream& os, const file_ty
pe type) pe type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case arma_binary: case arma_binary:
diskio::save_arma_binary(x, "[ostream]", os); return diskio::save_arma_binary(x, os, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::save_ppm_binary(x, "[ostream]", os); return diskio::save_ppm_binary(x, os, err_msg);
break; break;
default: default:
arma_stop("field_aux::save(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Cube<eT> >& x, const std::string& name, const file_t field_aux::load(field< Cube<eT> >& x, const std::string& name, const file_t
ype type) ype type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, name); return diskio::load_auto_detect(x, name, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, name); return diskio::load_arma_binary(x, name, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, name); return diskio::load_ppm_binary(x, name, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
template<typename eT> template<typename eT>
inline inline
void bool
field_aux::load(field< Cube<eT> >& x, std::istream& is, const file_type typ field_aux::load(field< Cube<eT> >& x, std::istream& is, const file_type typ
e) e, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(type) switch(type)
{ {
case auto_detect: case auto_detect:
diskio::load_auto_detect(x, "[istream]", is); return diskio::load_auto_detect(x, is, err_msg);
break; break;
case arma_binary: case arma_binary:
diskio::load_arma_binary(x, "[istream]", is); return diskio::load_arma_binary(x, is, err_msg);
break; break;
case ppm_binary: case ppm_binary:
diskio::load_ppm_binary(x, "[istream]", is); return diskio::load_ppm_binary(x, is, err_msg);
break; break;
default: default:
arma_stop("field_aux::load(): unsupported type"); err_msg = " [unsupported type] filename = ";
return false;
} }
} }
inline inline
void bool
field_aux::save(const field< std::string >& x, const std::string& name, con field_aux::save(const field< std::string >& x, const std::string& name, con
st file_type type) st file_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diskio::save_std_string(x, name); err_msg.clear();
return diskio::save_std_string(x, name);
} }
inline inline
void bool
field_aux::save(const field< std::string >& x, std::ostream& os, const file field_aux::save(const field< std::string >& x, std::ostream& os, const file
_type type) _type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diskio::save_std_string(x, "[ostream]", os); err_msg.clear();
return diskio::save_std_string(x, os);
} }
inline inline
void bool
field_aux::load(field< std::string >& x, const std::string& name, const fil field_aux::load(field< std::string >& x, const std::string& name, const fil
e_type type) e_type type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diskio::load_std_string(x, name); return diskio::load_std_string(x, name, err_msg);
} }
inline inline
void bool
field_aux::load(field< std::string >& x, std::istream& is, const file_type field_aux::load(field< std::string >& x, std::istream& is, const file_type
type) type, std::string& err_msg)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
diskio::load_std_string(x, "[istream]", is); return diskio::load_std_string(x, is, err_msg);
} }
//! @} //! @}
 End of changes. 96 change blocks. 
152 lines changed or deleted 294 lines changed or added


 field_proto.hpp   field_proto.hpp 
skipping to change at line 36 skipping to change at line 36
public: public:
typedef oT object_type; typedef oT object_type;
const u32 n_rows; //!< number of rows in the field (read-only) const u32 n_rows; //!< number of rows in the field (read-only)
const u32 n_cols; //!< number of columns in the field (read-only) const u32 n_cols; //!< number of columns in the field (read-only)
const u32 n_elem; //!< number of elements in the field (read-only) const u32 n_elem; //!< number of elements in the field (read-only)
private: private:
//! pointer to memory used by the object arma_aligned oT** mem; //!< pointer to memory used by the obj
arma_aligned oT** mem; ect
arma_aligned oT* mem_local[ 16 ]; arma_aligned oT* mem_local[ 16 ]; //!< Internal memory, to avoid calling
//!< Internal memory, to avoid calling the 'new' operator for small amoun the 'new' operator for small amounts of memory
ts of memory
public: public:
inline ~field(); inline ~field();
inline field(); inline field();
inline field(const field& x); inline field(const field& x);
inline const field& operator=(const field& x); inline const field& operator=(const field& x);
inline field(const subview_field<oT>& x); inline field(const subview_field<oT>& x);
skipping to change at line 96 skipping to change at line 94
inline const subview_field<oT> subfield(const u32 in_row1, const u32 in_c ol1, const u32 in_row2, const u32 in_col2) const; inline const subview_field<oT> subfield(const u32 in_row1, const u32 in_c ol1, const u32 in_row2, const u32 in_col2) const;
inline void print(const std::string extra_text = "") const; inline void print(const std::string extra_text = "") const;
inline void print(std::ostream& user_stream, const std::string extra_text = "") const; inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
inline void fill(const oT& x); inline void fill(const oT& x);
inline void reset(); inline void reset();
inline void reset_objects(); inline void reset_objects();
inline void save(const std::string name, const file_type type = arma_bi inline bool save(const std::string name, const file_type type = arma_bi
nary) const; nary, const bool print_status = true) const;
inline void save( std::ostream& os, const file_type type = arma_bi inline bool save( std::ostream& os, const file_type type = arma_bi
nary) const; nary, const bool print_status = true) const;
inline void load(const std::string name, const file_type type = auto_de inline bool load(const std::string name, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline void load( std::istream& is, const file_type type = auto_de inline bool load( std::istream& is, const file_type type = auto_de
tect); tect, const bool print_status = true);
inline bool quiet_save(const std::string name, const file_type type = a
rma_binary) const;
inline bool quiet_save( std::ostream& os, const file_type type = a
rma_binary) const;
inline bool quiet_load(const std::string name, const file_type type = a
uto_detect);
inline bool quiet_load( std::istream& is, const file_type type = a
uto_detect);
// iterators // iterators
class iterator class iterator
{ {
public: public:
inline iterator(field<oT>& in_M, const bool at_end = false); inline iterator(field<oT>& in_M, const bool at_end = false);
inline oT& operator* (); inline oT& operator* ();
skipping to change at line 176 skipping to change at line 180
{ {
public: public:
template<typename oT> inline static void reset_objects(field< oT >& x); template<typename oT> inline static void reset_objects(field< oT >& x);
template<typename eT> inline static void reset_objects(field< Mat<eT> >& x); template<typename eT> inline static void reset_objects(field< Mat<eT> >& x);
template<typename eT> inline static void reset_objects(field< Col<eT> >& x); template<typename eT> inline static void reset_objects(field< Col<eT> >& x);
template<typename eT> inline static void reset_objects(field< Row<eT> >& x); template<typename eT> inline static void reset_objects(field< Row<eT> >& x);
template<typename eT> inline static void reset_objects(field< Cube<eT> >& x); template<typename eT> inline static void reset_objects(field< Cube<eT> >& x);
inline static void reset_objects(field< std::string >& x); inline static void reset_objects(field< std::string >& x);
template<typename oT> inline static void save(const field< oT >& x, template<typename oT> inline static bool save(const field< oT >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename oT> inline static void save(const field< oT >& x, template<typename oT> inline static bool save(const field< oT >& x,
std::ostream& os, const file_type type); std::ostream& os, const file_type type, std::string& err_msg);
template<typename oT> inline static void load( field< oT >& x, template<typename oT> inline static bool load( field< oT >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename oT> inline static void load( field< oT >& x, template<typename oT> inline static bool load( field< oT >& x,
std::istream& is, const file_type type); std::istream& is, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Mat<eT> >& x, template<typename eT> inline static bool save(const field< Mat<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Mat<eT> >& x, template<typename eT> inline static bool save(const field< Mat<eT> >& x,
std::ostream& os, const file_type type); std::ostream& os, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Mat<eT> >& x, template<typename eT> inline static bool load( field< Mat<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Mat<eT> >& x, template<typename eT> inline static bool load( field< Mat<eT> >& x,
std::istream& is, const file_type type); std::istream& is, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Col<eT> >& x, template<typename eT> inline static bool save(const field< Col<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Col<eT> >& x, template<typename eT> inline static bool save(const field< Col<eT> >& x,
std::ostream& os, const file_type type); std::ostream& os, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Col<eT> >& x, template<typename eT> inline static bool load( field< Col<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Col<eT> >& x, template<typename eT> inline static bool load( field< Col<eT> >& x,
std::istream& is, const file_type type); std::istream& is, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Row<eT> >& x, template<typename eT> inline static bool save(const field< Row<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Row<eT> >& x, template<typename eT> inline static bool save(const field< Row<eT> >& x,
std::ostream& os, const file_type type); std::ostream& os, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Row<eT> >& x, template<typename eT> inline static bool load( field< Row<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Row<eT> >& x, template<typename eT> inline static bool load( field< Row<eT> >& x,
std::istream& is, const file_type type); std::istream& is, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Cube<eT> >& x, template<typename eT> inline static bool save(const field< Cube<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void save(const field< Cube<eT> >& x, template<typename eT> inline static bool save(const field< Cube<eT> >& x,
std::ostream& os, const file_type type); std::ostream& os, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Cube<eT> >& x, template<typename eT> inline static bool load( field< Cube<eT> >& x,
const std::string& name, const file_type type); const std::string& name, const file_type type, std::string& err_msg);
template<typename eT> inline static void load( field< Cube<eT> >& x, template<typename eT> inline static bool load( field< Cube<eT> >& x,
std::istream& is, const file_type type); std::istream& is, const file_type type, std::string& err_msg);
inline static void save(const field< std::string >& inline static bool save(const field< std::string >& x, const std::string&
x, const std::string& name, const file_type type); name, const file_type type, std::string& err_msg);
inline static void save(const field< std::string >& inline static bool save(const field< std::string >& x, std::ostream& os,
x, std::ostream& os, const file_type type); const file_type type, std::string& err_msg);
inline static void load( field< std::string >& inline static bool load( field< std::string >& x, const std::string&
x, const std::string& name, const file_type type); name, const file_type type, std::string& err_msg);
inline static void load( field< std::string >& inline static bool load( field< std::string >& x, std::istream& is,
x, std::istream& is, const file_type type); const file_type type, std::string& err_msg);
}; };
//! @} //! @}
 End of changes. 4 change blocks. 
66 lines changed or deleted 75 lines changed or added


 fn_chol.hpp   fn_chol.hpp 
skipping to change at line 22 skipping to change at line 22
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_chol //! \addtogroup fn_chol
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_chol> const Op<T1, op_chol>
chol(const Base<typename T1::elem_type,T1>& X) chol(const Base<typename T1::elem_type,T1>& X, const typename arma_blas_typ e_only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_chol>(X.get_ref()); return Op<T1, op_chol>(X.get_ref());
} }
template<typename T1> template<typename T1>
inline inline
bool bool
chol(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type,T1 >& X) chol(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type,T1 >& X, const typename arma_blas_type_only<typename T1::elem_type>::result* j unk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = chol(X); out = chol(X);
return (out.n_elem == 0) ? false : true; return (out.n_elem == 0) ? false : true;
} }
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_conv_to.hpp   fn_conv_to.hpp 
skipping to change at line 19 skipping to change at line 19
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_conv_to //! \addtogroup fn_conv_to
//! @{ //! @{
// //! conversion from Armadillo Base and BaseCube objects to scalars
// //! (kept only for compatibility with old code; use as_scalar() instead for
// conversions between various mat types Base objects like Mat)
template<typename out_eT, typename in_eT>
arma_inline
void
copy_complex_elem(out_eT& out, const in_eT& in)
{
//arma_extra_debug_sigprint();
out = out_eT(in);
}
template<typename out_eT, typename in_T>
arma_inline
void
copy_complex_elem(out_eT& out, const std::complex<in_T>& in)
{
//arma_extra_debug_sigprint();
out = out_eT( in.real() );
}
template<typename out_T, typename in_T>
arma_inline
void
copy_complex_elem(std::complex<out_T>& out, const std::complex<in_T>& in)
{
//arma_extra_debug_sigprint();
typedef std::complex<out_T> out_eT;
out = out_eT(in);
}
//
// scalar family
template<typename out_eT> template<typename out_eT>
class conv_to class conv_to
{ {
public: public:
inline static out_eT from(const Mat< out_eT >& in);
template<typename in_eT>
inline static out_eT from(const Mat< in_eT >& in);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static out_eT from(const Base<in_eT,T1>& in); inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_
not_cx<in_eT>::result* junk = 0);
//
inline static out_eT from(const Cube< out_eT >& in); template<typename in_eT, typename T1>
inline static out_eT from(const Base<in_eT, T1>& in, const typename arma_
cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT, typename T1>
inline static out_eT from(const Cube< in_eT >& in); inline static out_eT from(const BaseCube<in_eT, T1>& in, const typename a
rma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static out_eT from(const BaseCube<in_eT,T1>& in); inline static out_eT from(const BaseCube<in_eT, T1>& in, const typename a rma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const Mat<out_eT>& in) conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_not_cx
{ <in_eT>::result* junk)
arma_extra_debug_sigprint();
arma_debug_check( (in.n_elem != 1), "conv_to<>: matrix doesn't have exact
ly one element" );
return in.mem[0];
}
template<typename out_eT>
template<typename in_eT>
inline
out_eT
conv_to<out_eT>::from(const Mat<in_eT>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( );
arma_debug_check( (in.n_elem != 1), "conv_to<>: matrix doesn't have exact const unwrap<T1> tmp(in.get_ref());
ly one element" ); const Mat<in_eT>& X = tmp.M;
out_eT out; arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
copy_complex_elem(out, in.mem[0]); exactly one element" );
return out; return out_eT(X.mem[0]);
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const Base<in_eT,T1>& in) conv_to<out_eT>::from(const Base<in_eT, T1>& in, const typename arma_cx_onl y<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( );
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M;
return conv_to<out_eT>::from( tmp.M ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
} exactly one element" );
template<typename out_eT> out_eT out;
inline
out_eT
conv_to<out_eT>::from(const Cube<out_eT>& in)
{
arma_extra_debug_sigprint();
arma_debug_check( (in.n_elem != 1), "conv_to<>: cube doesn't have exactly one element" ); syslib::convert_cx_scalar(out, X.mem[0]);
return in.mem[0]; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const Cube<in_eT>& in) conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_no t_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( );
arma_debug_check( (in.n_elem != 1), "conv_to<>: cube doesn't have exactly const unwrap_cube<T1> tmp(in.get_ref());
one element" ); const Cube<in_eT>& X = tmp.M;
out_eT out; arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
copy_complex_elem(out, in.mem[0]); exactly one element" );
return out; return out_eT(X.mem[0]);
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
out_eT out_eT
conv_to<out_eT>::from(const BaseCube<in_eT,T1>& in) conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_cx _only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( ); arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply( );
const unwrap_cube<T1> tmp(in.get_ref()); const unwrap_cube<T1> tmp(in.get_ref());
const Cube<in_eT>& X = tmp.M;
return conv_to<out_eT>::from( tmp.M ); arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
} exactly one element" );
out_eT out;
syslib::convert_cx_scalar(out, X.mem[0]);
// return out;
// }
// Mat family
//! conversion to Armadillo matrices from Armadillo Base objects,
//! as well as from std::vector, itpp::Mat and itpp::Vec
template<typename out_eT> template<typename out_eT>
class conv_to< Mat<out_eT> > class conv_to< Mat<out_eT> >
{ {
public: public:
template<typename in_eT, typename T1>
inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1>
inline static Mat<out_eT> from(const Base<in_eT, T1>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Mat<out_eT> from(const Mat< in_eT >& in); inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0);
template<typename in_T> template<typename in_eT>
inline static Mat<out_eT> from(const Mat< std::complex<in_T> >& in); inline static Mat<out_eT> from(const std::vector<in_eT>& in, const typena
me arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT>
inline static Mat<out_eT> from(const Base<in_eT,T1>& in); inline static Mat<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
// template<typename in_eT> template<typename in_eT>
// inline static Mat<out_eT> from(const std::vector< in_eT >& in); inline static Mat<out_eT> from(const itpp::Mat<in_eT>& in, const typename
// arma_cx_only<in_eT>::result* junk = 0);
// template<typename in_eT>
// inline static Mat<out_eT> from(const std::vector< std::complex<in_eT>
>& in);
template<typename in_eT> template<typename in_eT>
inline static Mat<out_eT> from(const itpp::Mat< in_eT >& in); inline static Mat<out_eT> from(const itpp::Vec<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_T> template<typename in_eT>
inline static Mat<out_eT> from(const itpp::Mat< std::complex<in_T> >& in) inline static Mat<out_eT> from(const itpp::Vec<in_eT>& in, const typename
; arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT, typename T1>
inline inline
Mat<out_eT> Mat<out_eT>
conv_to< Mat<out_eT> >::from(const Mat<in_eT>& in) conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<out_eT> out(in.n_rows, in.n_cols); const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M;
const in_eT* in_mem = in.mem; Mat<out_eT> out(X.n_rows, X.n_cols);
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem );
{
out_mem[i] = out_eT( in_mem[i] );
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT, typename T1>
inline inline
Mat<out_eT> Mat<out_eT>
conv_to< Mat<out_eT> >::from(const Mat< std::complex<in_T> >& in) conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma _cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M;
Mat<out_eT> out(in.n_rows, in.n_cols); Mat<out_eT> out(X.n_rows, X.n_cols);
const in_eT* in_mem = in.mem; syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem );
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i)
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT>
inline inline
Mat<out_eT> Mat<out_eT>
conv_to< Mat<out_eT> >::from(const Base<in_eT,T1>& in) conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename a rma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); Mat<out_eT> out(in.size(), 1);
return conv_to< Mat<out_eT> >::from( tmp.M );
}
template<typename out_eT> typename std::vector<in_eT>::const_iterator in_begin = in.begin();
template<typename in_eT> typename std::vector<in_eT>::const_iterator in_end = in.end();
inline
Mat<out_eT>
conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in)
{
arma_extra_debug_sigprint();
Mat<out_eT> out(in.rows(), in.cols()); typename Mat<out_eT>::iterator out_begin = out.begin();
typename Mat<out_eT>::iterator out_end = out.end();
const in_eT* in_mem = in._data(); typename std::vector<in_eT>::const_iterator in_it;
out_eT* out_mem = out.memptr(); typename Mat<out_eT>::iterator out_it;
for(u32 i=0; i<out.n_elem; ++i) for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
{ {
out_mem[i] = out_eT( in_mem[i] ); (*out_it) = out_eT(*in_it);
} }
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
Mat<out_eT> Mat<out_eT>
conv_to< Mat<out_eT> >::from(const itpp::Mat< std::complex<in_T> >& in) conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename a rma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; Mat<out_eT> out(in.size(), 1);
Mat<out_eT> out(in.rows(), in.cols());
const in_eT* in_mem = in._data();
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) typename std::vector<in_eT>::const_iterator in_begin = in.begin();
{ typename std::vector<in_eT>::const_iterator in_end = in.end();
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out;
}
//
//
// Row family
template<typename out_eT> typename Mat<out_eT>::iterator out_begin = out.begin();
class conv_to< Row<out_eT> > typename Mat<out_eT>::iterator out_end = out.end();
{
public:
inline static Row<out_eT> from(const Mat< out_eT >& in);
template<typename in_eT> typename std::vector<in_eT>::const_iterator in_it;
inline static Row<out_eT> from(const Mat< in_eT >& in); typename Mat<out_eT>::iterator out_it;
template<typename in_T> for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
inline static Row<out_eT> from(const Mat< std::complex<in_T> >& in); out_end); ++in_it, ++out_it)
{
template<typename in_eT, typename T1> out_eT& out_elem = (*out_it);
inline static Row<out_eT> from(const Base<in_eT,T1>& in); const in_eT& in_elem = (*in_it);
template<typename in_eT>
inline static Row<out_eT> from(const itpp::Vec< in_eT >& in);
template<typename in_T>
inline static Row<out_eT> from(const itpp::Vec< std::complex<in_T> >& in)
;
//inline static Row<out_eT> from(const Col< out_eT >& in);
//template<typename in_eT> inline static Row<out_eT> from(const Col< in_e
T >& in);
//template<typename in_T> inline static Row<out_eT> from(const Col< std:
:complex<in_T> >& in);
};
template<typename out_eT>
inline
Row<out_eT>
conv_to< Row<out_eT> >::from(const Mat<out_eT>& in)
{
arma_extra_debug_sigprint();
arma_debug_check( (in.n_rows > 1), "conv_to<>: given matrix has more than
one row");
Row<out_eT> out(in.n_cols);
syslib::copy_elem(out.memptr(), in.mem, out.n_elem); syslib::convert_cx_scalar(out_elem, in_elem);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
Row<out_eT> Mat<out_eT>
conv_to< Row<out_eT> >::from(const Mat<in_eT>& in) conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (in.n_rows > 1), "conv_to<>: given matrix has more than Mat<out_eT> out(in.rows(), in.cols());
one row");
Row<out_eT> out(in.n_cols);
const in_eT* in_mem = in.mem;
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem );
{
out_mem[i] = out_eT( in_mem[i] );
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
Row<out_eT> Mat<out_eT>
conv_to< Row<out_eT> >::from(const Mat< std::complex<in_T> >& in) conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; Mat<out_eT> out(in.rows(), in.cols());
arma_debug_check( (in.n_rows > 1), "conv_to<>: given matrix has more than
one row");
Row<out_eT> out(in.n_cols);
const in_eT* in_mem = in.mem;
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem );
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1>
inline
Row<out_eT>
conv_to< Row<out_eT> >::from(const Base<in_eT,T1>& in)
{
arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref());
return conv_to< Row<out_eT> >::from( tmp.M );
}
template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
Row<out_eT> Mat<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in) conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Row<out_eT> out(in.length()); Mat<out_eT> out(in.length(), 1);
const in_eT* in_mem = in._data();
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem );
{
out_mem[i] = out_eT( in_mem[i] );
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
Row<out_eT> Mat<out_eT>
conv_to< Row<out_eT> >::from(const itpp::Vec< std::complex<in_T> >& in) conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; Mat<out_eT> out(in.length(), 1);
Row<out_eT> out(in.length());
const in_eT* in_mem = in._data();
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem );
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
// template<typename out_eT> //! conversion to Armadillo row vectors from Armadillo Base objects,
// inline //! as well as from std::vector, itpp::Mat and itpp::Vec
// Row<out_eT>
// conv_to< Row<out_eT> >::from(const Col<out_eT>& in)
// {
// arma_extra_debug_sigprint();
//
// return trans(in);
// }
//
//
//
// template<typename out_eT>
// template<typename in_eT>
// inline
// Row<out_eT>
// conv_to< Row<out_eT> >::from(const Col<in_eT>& in)
// {
// arma_extra_debug_sigprint();
//
// Row<out_eT> out(in.n_rows);
//
// const in_eT* in_mem = in.mem;
// out_eT* out_mem = out.memptr();
//
// for(u32 i=0; i<out.n_elem; ++i)
// {
// out_mem[i] = out_eT( in_mem[i] );
// }
//
// return out;
// }
//
//
//
// template<typename out_eT>
// template<typename in_T>
// inline
// Row<out_eT>
// conv_to< Row<out_eT> >::from(const Col< std::complex<in_T> >& in)
// {
// arma_extra_debug_sigprint();
//
// typedef std::complex<in_T> in_eT;
//
// Row<out_eT> out(in.n_rows);
//
// const in_eT* in_mem = in.mem;
// out_eT* out_mem = out.memptr();
//
// for(u32 i=0; i<out.n_elem; ++i)
// {
// copy_complex_elem(out_mem[i], in_mem[i]);
// }
//
// return out;
// }
//
//
// Col family
template<typename out_eT> template<typename out_eT>
class conv_to< Col<out_eT> > class conv_to< Row<out_eT> >
{ {
public: public:
inline static Col<out_eT> from(const Mat< out_eT >& in); template<typename in_eT, typename T1>
inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT, typename T1>
inline static Col<out_eT> from(const Mat< in_eT >& in); inline static Row<out_eT> from(const Base<in_eT, T1>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
template<typename in_T> template<typename in_eT>
inline static Col<out_eT> from(const Mat< std::complex<in_T> >& in); inline static Row<out_eT> from(const std::vector<in_eT>& in, const typena
me arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT>
inline static Col<out_eT> from(const Base<in_eT,T1>& in); inline static Row<out_eT> from(const std::vector<in_eT>& in, const typena
me arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static Col<out_eT> from(const itpp::Vec< in_eT >& in); inline static Row<out_eT> from(const itpp::Mat<in_eT>& in, const typename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_T> template<typename in_eT>
inline static Col<out_eT> from(const itpp::Vec< std::complex<in_T> >& in) inline static Row<out_eT> from(const itpp::Mat<in_eT>& in, const typename
; arma_cx_only<in_eT>::result* junk = 0);
// inline static Col<out_eT> from(const Row< out_eT >& in); template<typename in_eT>
// template<typename in_eT> inline static Col<out_eT> from(const Row< in_ inline static Row<out_eT> from(const itpp::Vec<in_eT>& in, const typename
eT >& in); arma_not_cx<in_eT>::result* junk = 0);
// template<typename in_T> inline static Col<out_eT> from(const Row< std
::complex<in_T> >& in);
template<typename in_eT>
inline static Row<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
Col<out_eT> Row<out_eT>
conv_to< Col<out_eT> >::from(const Mat<out_eT>& in) conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (in.n_cols > 1), "conv_to<>: given matrix has more than const unwrap<T1> tmp(in.get_ref());
one column"); const Mat<in_eT>& X = tmp.M;
Col<out_eT> out(in.n_rows);
arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" );
Row<out_eT> out(X.n_elem);
syslib::copy_elem(out.memptr(), in.mem, out.n_elem); syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem );
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT, typename T1>
inline inline
Col<out_eT> Row<out_eT>
conv_to< Col<out_eT> >::from(const Mat<in_eT>& in) conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (in.n_cols > 1), "conv_to<>: given matrix has more than const unwrap<T1> tmp(in.get_ref());
one column"); const Mat<in_eT>& X = tmp.M;
Col<out_eT> out(in.n_rows);
const in_eT* in_mem = in.mem; arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
out_eT* out_mem = out.memptr(); e interpreted as a vector" );
for(u32 i=0; i<out.n_elem; ++i) Row<out_eT> out(X.n_rows, X.n_cols);
{
out_mem[i] = out_eT( in_mem[i] ); syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem );
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
Col<out_eT> Row<out_eT>
conv_to< Col<out_eT> >::from(const Mat< std::complex<in_T> >& in) conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; Row<out_eT> out( in.size() );
typename std::vector<in_eT>::const_iterator in_begin = in.begin();
typename std::vector<in_eT>::const_iterator in_end = in.end();
arma_debug_check( (in.n_cols > 1), "conv_to<>: given matrix has more than typename Col<out_eT>::iterator out_begin = out.begin();
one column"); typename Col<out_eT>::iterator out_end = out.end();
Col<out_eT> out(in.n_rows);
const in_eT* in_mem = in.mem; typename std::vector<in_eT>::const_iterator in_it;
out_eT* out_mem = out.memptr(); typename Col<out_eT>::iterator out_it;
for(u32 i=0; i<out.n_elem; ++i) for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
{ {
copy_complex_elem(out_mem[i], in_mem[i]); (*out_it) = out_eT(*in_it);
} }
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT>
inline inline
Col<out_eT> Row<out_eT>
conv_to< Col<out_eT> >::from(const Base<in_eT,T1>& in) conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); Row<out_eT> out( in.size() );
return conv_to< Col<out_eT> >::from( tmp.M ); typename std::vector<in_eT>::const_iterator in_begin = in.begin();
} typename std::vector<in_eT>::const_iterator in_end = in.end();
template<typename out_eT>
template<typename in_eT>
inline
Col<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in)
{
arma_extra_debug_sigprint();
Col<out_eT> out(in.length()); typename Col<out_eT>::iterator out_begin = out.begin();
typename Col<out_eT>::iterator out_end = out.end();
const in_eT* in_mem = in._data(); typename std::vector<in_eT>::const_iterator in_it;
out_eT* out_mem = out.memptr(); typename Col<out_eT>::iterator out_it;
for(u32 i=0; i<out.n_elem; ++i) for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it != out_end); ++in_it, ++out_it)
{ {
out_mem[i] = out_eT( in_mem[i] ); out_eT& out_elem = (*out_it);
const in_eT& in_elem = (*in_it);
syslib::convert_cx_scalar(out_elem, in_elem);
} }
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
Col<out_eT> Row<out_eT>
conv_to< Col<out_eT> >::from(const itpp::Vec< std::complex<in_T> >& in) conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
Col<out_eT> out(in.length()); arma_debug_check( (is_vec == false), "conv_to(): given object can't be in terpreted as a vector" );
const in_eT* in_mem = in._data(); Row<out_eT> out(in.rows() * in.cols());
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem );
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
// template<typename out_eT>
// inline
// Col<out_eT>
// conv_to< Col<out_eT> >::from(const Row<out_eT>& in)
// {
// arma_extra_debug_sigprint();
//
// return trans(in);
// }
//
//
//
// template<typename out_eT>
// template<typename in_eT>
// inline
// Col<out_eT>
// conv_to< Col<out_eT> >::from(const Row<in_eT>& in)
// {
// arma_extra_debug_sigprint();
//
// Col<out_eT> out(in.n_cols);
//
// const in_eT* in_mem = in.mem;
// out_eT* out_mem = out.memptr();
//
// for(u32 i=0; i<out.n_elem; ++i)
// {
// out_mem[i] = out_eT( in_mem[i] );
// }
//
// return out;
// }
//
//
//
// template<typename out_eT>
// template<typename in_T>
// inline
// Col<out_eT>
// conv_to< Col<out_eT> >::from(const Row< std::complex<in_T> >& in)
// {
// arma_extra_debug_sigprint();
//
// typedef std::complex<in_T> in_eT;
//
// Col<out_eT> out(in.n_cols);
//
// const in_eT* in_mem = in.mem;
// out_eT* out_mem = out.memptr();
//
// for(u32 i=0; i<out.n_elem; ++i)
// {
// copy_complex_elem(out_mem[i], in_mem[i]);
// }
//
// return out;
// }
//
//
// Cube family
template<typename out_eT>
class conv_to< Cube<out_eT> >
{
public:
template<typename in_eT>
inline static Cube<out_eT> from(const Cube< in_eT >& in);
template<typename in_T>
inline static Cube<out_eT> from(const Cube< std::complex<in_T> >& in);
template<typename in_eT, typename T1>
inline static Cube<out_eT> from(const BaseCube<in_eT,T1>& in);
};
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
Cube<out_eT> Row<out_eT>
conv_to< Cube<out_eT> >::from(const Cube<in_eT>& in) conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Cube<out_eT> out(in.n_rows, in.n_cols, in.n_slices); const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
const in_eT* in_mem = in.mem; Row<out_eT> out(in.rows() * in.cols());
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem );
{
out_mem[i] = out_eT( in_mem[i] );
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
Cube<out_eT> Row<out_eT>
conv_to< Cube<out_eT> >::from(const Cube< std::complex<in_T> >& in) conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; Row<out_eT> out(in.length());
Cube<out_eT> out(in.n_rows, in.n_cols, in.n_slices);
const in_eT* in_mem = in.mem;
out_eT* out_mem = out.memptr();
for(u32 i=0; i<out.n_elem; ++i) syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem );
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT>
inline inline
Cube<out_eT> Row<out_eT>
conv_to< Cube<out_eT> >::from(const BaseCube<in_eT,T1>& in) conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(in.get_ref()); Row<out_eT> out(in.length());
return conv_to< Mat<out_eT> >::from( tmp.M ); syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem );
}
// return out;
// }
// itpp::Mat family
//! conversion to Armadillo column vectors from Armadillo Base objects,
//! as well as from std::vector, itpp::Mat and itpp::Vec
template<typename out_eT> template<typename out_eT>
class conv_to< itpp::Mat<out_eT> > class conv_to< Col<out_eT> >
{ {
public: public:
inline static itpp::Mat<out_eT> from(const Mat< out_eT >& in); template<typename in_eT, typename T1>
inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename
inline static itpp::Mat<out_eT> from(const Col< out_eT >& in); arma_not_cx<in_eT>::result* junk = 0);
inline static itpp::Mat<out_eT> from(const Row< out_eT >& in); template<typename in_eT, typename T1>
inline static Col<out_eT> from(const Base<in_eT, T1>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static itpp::Mat<out_eT> from(const Mat< in_eT >& in); inline static Col<out_eT> from(const std::vector<in_eT>& in, const typena me arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static itpp::Mat<out_eT> from(const Col< in_eT >& in); inline static Col<out_eT> from(const std::vector<in_eT>& in, const typena me arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT> template<typename in_eT>
inline static itpp::Mat<out_eT> from(const Row< in_eT >& in); inline static Col<out_eT> from(const itpp::Mat<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_T>
inline static itpp::Mat<out_eT> from(const Mat< std::complex<in_T> >& in)
;
template<typename in_T>
inline static itpp::Mat<out_eT> from(const Col< std::complex<in_T> >& in)
;
template<typename in_T> template<typename in_eT>
inline static itpp::Mat<out_eT> from(const Row< std::complex<in_T> >& in) inline static Col<out_eT> from(const itpp::Mat<in_eT>& in, const typename
; arma_cx_only<in_eT>::result* junk = 0);
template<typename in_eT, typename T1> template<typename in_eT>
inline static itpp::Mat<out_eT> from(const Base<in_eT,T1>& in); inline static Col<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT>
inline static Col<out_eT> from(const itpp::Vec<in_eT>& in, const typename
arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Mat<out_eT>& in) conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
itpp::Mat<out_eT> out(in.n_rows, in.n_cols); const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M;
arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" );
Col<out_eT> out(X.n_elem);
syslib::copy_elem(out._data(), in.mem, in.n_elem); syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem );
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Col<out_eT>& in) conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return conv_to< itpp::Mat<out_eT> >::from( reinterpret_cast<const Mat<out const unwrap<T1> tmp(in.get_ref());
_eT>& >(in) ); const Mat<in_eT>& X = tmp.M;
}
template<typename out_eT> arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
inline e interpreted as a vector" );
itpp::Mat<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Row<out_eT>& in)
{
arma_extra_debug_sigprint();
return conv_to< itpp::Mat<out_eT> >::from( reinterpret_cast<const Mat<out Col<out_eT> out(X.n_rows, X.n_cols);
_eT>& >(in) );
syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem );
return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Mat<in_eT>& in) conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
itpp::Mat<out_eT> out(in.n_rows, in.n_cols); Col<out_eT> out( in.size() );
typename std::vector<in_eT>::const_iterator in_begin = in.begin();
typename std::vector<in_eT>::const_iterator in_end = in.end();
const in_eT* in_mem = in.memptr(); typename Col<out_eT>::iterator out_begin = out.begin();
out_eT* out_mem = out._data(); typename Col<out_eT>::iterator out_end = out.end();
for(u32 i=0; i<in.n_elem; ++i) typename std::vector<in_eT>::const_iterator in_it;
typename Col<out_eT>::iterator out_it;
for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it)
{ {
out_mem[i] = out_eT( in_mem[i] ); (*out_it) = out_eT(*in_it);
} }
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Col<in_eT>& in) conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return conv_to< itpp::Mat<out_eT> >::from( reinterpret_cast<const Mat<in_ Col<out_eT> out( in.size() );
eT>& >(in) );
}
template<typename out_eT> typename std::vector<in_eT>::const_iterator in_begin = in.begin();
template<typename in_eT> typename std::vector<in_eT>::const_iterator in_end = in.end();
inline
itpp::Mat<out_eT> typename Col<out_eT>::iterator out_begin = out.begin();
conv_to< itpp::Mat<out_eT> >::from(const Row<in_eT>& in) typename Col<out_eT>::iterator out_end = out.end();
{
arma_extra_debug_sigprint(); typename std::vector<in_eT>::const_iterator in_it;
typename Col<out_eT>::iterator out_it;
for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it)
{
out_eT& out_elem = (*out_it);
const in_eT& in_elem = (*in_it);
syslib::convert_cx_scalar(out_elem, in_elem);
}
return conv_to< itpp::Mat<out_eT> >::from( reinterpret_cast<const Mat<in_ eT>& >(in) ); return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Mat< std::complex<in_T> >& in) conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
itpp::Mat<out_eT> out(in.n_rows, in.n_cols); arma_debug_check( (is_vec == false), "conv_to(): given object can't be in terpreted as a vector" );
const in_eT* in_mem = in.memptr(); Col<out_eT> out(in.rows() * in.cols());
out_eT* out_mem = out._data();
for(u32 i=0; i<in.n_elem; ++i) syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem );
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Col< std::complex<in_T> >& in) conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return conv_to< itpp::Mat<out_eT> >::from( reinterpret_cast<const Mat< st const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) );
d::complex<in_T> >& >(in) );
Col<out_eT> out(in.rows() * in.cols());
syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem );
return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Row< std::complex<in_T> >& in) conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return conv_to< itpp::Mat<out_eT> >::from( reinterpret_cast<const Mat< st Col<out_eT> out( in.length() );
d::complex<in_T> >& >(in) );
syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem );
return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT>
inline inline
itpp::Mat<out_eT> Col<out_eT>
conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT,T1>& in) conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); Col<out_eT> out( in.length() );
return conv_to< itpp::Mat<out_eT> >::from( tmp.M ); syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem );
}
// return out;
// }
// itpp::Vec family
//! conversion to Armadillo cubes from Armadillo BaseCube objects
template<typename out_eT> template<typename out_eT>
class conv_to< itpp::Vec<out_eT> > class conv_to< Cube<out_eT> >
{ {
public: public:
inline static itpp::Vec<out_eT> from(const Mat< out_eT >& in); template<typename in_eT, typename T1>
inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const type
template<typename in_eT> name arma_not_cx<in_eT>::result* junk = 0);
inline static itpp::Vec<out_eT> from(const Mat< in_eT >& in);
template<typename in_T>
inline static itpp::Vec<out_eT> from(const Mat< std::complex<in_T> >& in)
;
template<typename in_eT>
inline static itpp::Vec<out_eT> from(const Col< in_eT >& in);
template<typename in_eT>
inline static itpp::Vec<out_eT> from(const Row< in_eT >& in);
template<typename in_T>
inline static itpp::Vec<out_eT> from(const Col< std::complex<in_T> >& in)
;
template<typename in_T>
inline static itpp::Vec<out_eT> from(const Row< std::complex<in_T> >& in)
;
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline static itpp::Vec<out_eT> from(const Base<in_eT,T1>& in); inline static Cube<out_eT> from(const BaseCube<in_eT, T1>& in, const type name arma_cx_only<in_eT>::result* junk = 0);
}; };
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> Cube<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Mat<out_eT>& in) conv_to< Cube<out_eT> >::from(const BaseCube<in_eT, T1>& in, const typename
arma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in.n_cols != 1) && (in.n_rows != 1) ), "conv_to<>: g const unwrap_cube<T1> tmp( in.get_ref() );
iven matrix can't be interpreted as a vector"); const Cube<in_eT>& X = tmp.M;
itpp::Vec<out_eT> out(in.n_elem); Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices);
syslib::copy_elem(out._data(), in.mem, in.n_elem); syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem );
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> Cube<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Mat<in_eT>& in) conv_to< Cube<out_eT> >::from(const BaseCube<in_eT, T1>& in, const typename
arma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in.n_cols != 1) && (in.n_rows != 1) ), "conv_to<>: g const unwrap_cube<T1> tmp( in.get_ref() );
iven matrix can't be interpreted as a vector"); const Cube<in_eT>& X = tmp.M;
itpp::Vec<out_eT> out(in.n_elem);
const in_eT* in_mem = in.memptr(); Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices);
out_eT* out_mem = out._data();
for(u32 i=0; i<in.n_elem; ++i) syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem );
{
out_mem[i] = out_eT( in_mem[i] );
}
return out; return out;
} }
//! conversion to std::vector from Armadillo Base objects
template<typename out_eT> template<typename out_eT>
template<typename in_T> class conv_to< std::vector<out_eT> >
{
public:
template<typename in_eT, typename T1>
inline static std::vector<out_eT> from(const Base<in_eT, T1>& in, const t
ypename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1>
inline static std::vector<out_eT> from(const Base<in_eT, T1>& in, const t
ypename arma_cx_only<in_eT>::result* junk = 0);
};
template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> std::vector<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Mat< std::complex<in_T> >& in) conv_to< std::vector<out_eT> >::from(const Base<in_eT, T1>& in, const typen
ame arma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M;
arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" );
arma_debug_check( ( (in.n_cols != 1) && (in.n_rows != 1) ), "conv_to<>: g iven matrix can't be interpreted as a vector"); std::vector<out_eT> out(X.n_elem);
itpp::Vec<out_eT> out(in.n_elem); typename Mat<in_eT>::const_iterator X_begin = X.begin();
typename Mat<in_eT>::const_iterator X_end = X.end();
const in_eT* in_mem = in.memptr(); typename std::vector<out_eT>::iterator out_begin = out.begin();
out_eT* out_mem = out._data(); typename std::vector<out_eT>::iterator out_end = out.end();
for(u32 i=0; i<in.n_elem; ++i) typename Mat<in_eT>::const_iterator X_it;
typename std::vector<out_eT>::iterator out_it;
for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out
_end); ++X_it, ++out_it)
{ {
copy_complex_elem(out_mem[i], in_mem[i]); (*out_it) = out_eT(*X_it);
} }
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> std::vector<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Col<in_eT>& in) conv_to< std::vector<out_eT> >::from(const Base<in_eT, T1>& in, const typen
ame arma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
itpp::Vec<out_eT> out(in.n_elem); const unwrap<T1> tmp(in.get_ref());
const Mat<in_eT>& X = tmp.M;
arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" );
std::vector<out_eT> out(X.n_elem);
const in_eT* in_mem = in.memptr(); typename Mat<in_eT>::const_iterator X_begin = X.begin();
out_eT* out_mem = out._data(); typename Mat<in_eT>::const_iterator X_end = X.end();
for(u32 i=0; i<in.n_elem; ++i) typename std::vector<out_eT>::iterator out_begin = out.begin();
typename std::vector<out_eT>::iterator out_end = out.end();
typename Mat<in_eT>::const_iterator X_it;
typename std::vector<out_eT>::iterator out_it;
for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out
_end); ++X_it, ++out_it)
{ {
out_mem[i] = out_eT( in_mem[i] ); out_eT& out_elem = (*out_it);
const in_eT& X_elem = (*X_it);
syslib::convert_cx_scalar(out_elem, X_elem);
} }
return out; return out;
} }
//! conversion to itpp::Mat from Armadillo Base objects
template<typename out_eT>
class conv_to< itpp::Mat<out_eT> >
{
public:
template<typename in_eT, typename T1>
inline static itpp::Mat<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1>
inline static itpp::Mat<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_cx_only<in_eT>::result* junk = 0);
};
template<typename out_eT> template<typename out_eT>
template<typename in_T> template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> itpp::Mat<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Col< std::complex<in_T> >& in) conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
itpp::Vec<out_eT> out(in.n_elem); itpp::Mat<out_eT> out(X.n_rows, X.n_cols);
const in_eT* in_mem = in.memptr(); syslib::copy_and_convert_elem( out._data(), X.memptr(), X.n_elem );
out_eT* out_mem = out._data();
for(u32 i=0; i<in.n_elem; ++i)
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT> template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> itpp::Mat<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Row<in_eT>& in) conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
itpp::Vec<out_eT> out(in.n_elem); const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
const in_eT* in_mem = in.memptr(); itpp::Mat<out_eT> out(X.n_rows, X.n_cols);
out_eT* out_mem = out._data();
for(u32 i=0; i<in.n_elem; ++i) syslib::copy_and_convert_cx_elem( out._data(), X.memptr(), X.n_elem );
{
out_mem[i] = out_eT( in_mem[i] );
}
return out; return out;
} }
//! conversion to itpp::Vec from Armadillo Base objects
template<typename out_eT> template<typename out_eT>
template<typename in_T> class conv_to< itpp::Vec<out_eT> >
{
public:
template<typename in_eT, typename T1>
inline static itpp::Vec<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_not_cx<in_eT>::result* junk = 0);
template<typename in_eT, typename T1>
inline static itpp::Vec<out_eT> from(const Base<in_eT, T1>& in, const typ
ename arma_cx_only<in_eT>::result* junk = 0);
};
template<typename out_eT>
template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> itpp::Vec<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Row< std::complex<in_T> >& in) conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT, T1>& in, const typenam e arma_not_cx<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef std::complex<in_T> in_eT; const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
itpp::Vec<out_eT> out(in.n_elem); arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b e interpreted as a vector" );
const in_eT* in_mem = in.memptr(); itpp::Vec<out_eT> out(X.n_elem);
out_eT* out_mem = out._data();
for(u32 i=0; i<in.n_elem; ++i) syslib::copy_and_convert_elem( out._data(), X.memptr(), X.n_elem );
{
copy_complex_elem(out_mem[i], in_mem[i]);
}
return out; return out;
} }
template<typename out_eT> template<typename out_eT>
template<typename in_eT, typename T1> template<typename in_eT, typename T1>
inline inline
itpp::Vec<out_eT> itpp::Vec<out_eT>
conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT,T1>& in) conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT, T1>& in, const typenam e arma_cx_only<in_eT>::result* junk)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref()); const unwrap<T1> tmp( in.get_ref() );
const Mat<in_eT>& X = tmp.M;
itpp::Vec<out_eT> out(X.n_elem);
return conv_to< itpp::Vec<out_eT> >::from( tmp.M ); syslib::copy_and_convert_cx_elem( out._data(), X.memptr(), X.n_elem );
return out;
} }
//! @} //! @}
 End of changes. 224 change blocks. 
700 lines changed or deleted 500 lines changed or added


 fn_det.hpp   fn_det.hpp 
skipping to change at line 24 skipping to change at line 24
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_det //! \addtogroup fn_det
//! @{ //! @{
//! determinant of mat //! determinant of mat
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det(const Base<typename T1::elem_type,T1>& X) det(const Base<typename T1::elem_type,T1>& X, const typename arma_blas_type _only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( !A.is_square(), "det(): matrix must be square" ); arma_debug_check( !A.is_square(), "det(): matrix must be square" );
skipping to change at line 68 skipping to change at line 68
} }
return val; return val;
} }
//! determinant of inv(A), without doing the inverse operation //! determinant of inv(A), without doing the inverse operation
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det(const Op<T1,op_inv>& in) det(const Op<T1,op_inv>& in, const typename arma_blas_type_only<typename T1 ::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
isnt_fltpt<eT>::check(); isnt_fltpt<eT>::check();
eT tmp = det(in.m); eT tmp = det(in.m);
arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" ); arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" );
return eT(1) / tmp; return eT(1) / tmp;
} }
//! determinant of trans(A) //! determinant of trans(A)
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det(const Op<T1,op_trans>& in) det(const Op<T1,op_trans>& in, const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& X = tmp.M; const Mat<eT>& X = tmp.M;
return det(X); return det(X);
} }
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 fn_dot.hpp   fn_dot.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_dot //! \addtogroup fn_dot
//! @{ //! @{
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
dot(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_ dot
type,T2>& B) (
const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return op_dot::apply(A,B); return op_dot::apply(A,B);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
norm_dot(const Base<typename T1::elem_type,T1>& A, const Base<typename T1:: norm_dot
elem_type,T2>& B) (
const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return op_norm_dot::apply(A,B); return op_norm_dot::apply(A,B);
} }
//! @} //! @}
 End of changes. 2 change blocks. 
4 lines changed or deleted 12 lines changed or added


 fn_eig.hpp   fn_eig.hpp 
skipping to change at line 28 skipping to change at line 28
//! @{ //! @{
// //
// symmetric/hermitian matrices // symmetric/hermitian matrices
// //
//! Eigenvalues of real/complex symmetric/hermitian matrix X //! Eigenvalues of real/complex symmetric/hermitian matrix X
template<typename T1> template<typename T1>
inline inline
void void
eig_sym(Col<typename T1::pod_type>& eigval, const Base<typename T1::elem_ty pe,T1>& X) eig_sym(Col<typename T1::pod_type>& eigval, const Base<typename T1::elem_ty pe,T1>& X, const typename arma_blas_type_only<typename T1::elem_type>::resu lt* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// unwrap_check not used as T1::elem_type and T1::pod_type may not be the same. // unwrap_check not used as T1::elem_type and T1::pod_type may not be the same.
// furthermore, it doesn't matter if A is an alias of S, as auxlib::eig() makes a copy of A // furthermore, it doesn't matter if A is an alias of S, as auxlib::eig() makes a copy of A
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
auxlib::eig_sym(eigval, A); auxlib::eig_sym(eigval, A);
} }
//! Eigenvalues of real/complex symmetric/hermitian matrix X //! Eigenvalues of real/complex symmetric/hermitian matrix X
template<typename T1> template<typename T1>
inline inline
Col<typename T1::pod_type> Col<typename T1::pod_type>
eig_sym(const Base<typename T1::elem_type,T1>& X) eig_sym(const Base<typename T1::elem_type,T1>& X, const typename arma_blas_ type_only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<typename T1::pod_type> out; Col<typename T1::pod_type> out;
eig_sym(out, X); eig_sym(out, X);
return out; return out;
} }
//! Eigenvalues and eigenvectors of real/complex symmetric/hermitian matrix X //! Eigenvalues and eigenvectors of real/complex symmetric/hermitian matrix X
template<typename T1> template<typename T1>
inline inline
void void
eig_sym eig_sym
( (
Col<typename T1::pod_type>& eigval, Col<typename T1::pod_type>& eigval,
Mat<typename T1::elem_type>& eigvec, Mat<typename T1::elem_type>& eigvec,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
auxlib::eig_sym(eigval, eigvec, A); auxlib::eig_sym(eigval, eigvec, A);
skipping to change at line 91 skipping to change at line 92
//! Eigenvalues and eigenvectors (both left and right) of general real/comp lex square matrix X //! Eigenvalues and eigenvectors (both left and right) of general real/comp lex square matrix X
template<typename T1> template<typename T1>
inline inline
void void
eig_gen eig_gen
( (
Col< std::complex<typename T1::pod_type> >& eigval, Col< std::complex<typename T1::pod_type> >& eigval,
Mat<typename T1::elem_type>& l_eigvec, Mat<typename T1::elem_type>& l_eigvec,
Mat<typename T1::elem_type>& r_eigvec, Mat<typename T1::elem_type>& r_eigvec,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
auxlib::eig_gen(eigval, l_eigvec, r_eigvec, A, 'b'); auxlib::eig_gen(eigval, l_eigvec, r_eigvec, A, 'b');
skipping to change at line 115 skipping to change at line 117
//! Optional argument 'side' specifies which eigenvectors should be compute d: //! Optional argument 'side' specifies which eigenvectors should be compute d:
//! 'r' for right (default) and 'l' for left. //! 'r' for right (default) and 'l' for left.
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
void void
eig_gen eig_gen
( (
Col< std::complex<eT> >& eigval, Col< std::complex<eT> >& eigval,
Mat< std::complex<eT> >& eigvec, Mat< std::complex<eT> >& eigvec,
const Base<eT, T1>& X, const Base<eT, T1>& X,
const char side = 'r' const char side = 'r',
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//std::cout << "real" << std::endl; //std::cout << "real" << std::endl;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
Mat<eT> dummy_eigvec; Mat<eT> dummy_eigvec;
skipping to change at line 140 skipping to change at line 143
case 'r': case 'r':
auxlib::eig_gen(eigval, dummy_eigvec, tmp_eigvec, A, side); auxlib::eig_gen(eigval, dummy_eigvec, tmp_eigvec, A, side);
break; break;
case 'l': case 'l':
auxlib::eig_gen(eigval, tmp_eigvec, dummy_eigvec, A, side); auxlib::eig_gen(eigval, tmp_eigvec, dummy_eigvec, A, side);
break; break;
default: default:
arma_stop("eig_gen(): parameter 'side' is invalid"); arma_stop("eig_gen(): parameter 'side' is invalid");
return;
} }
const u32 n = A.n_rows; const u32 n = A.n_rows;
if(n > 0) if(n > 0)
{ {
eigvec.set_size(n,n); eigvec.set_size(n,n);
for(u32 j=0; j<n; ++j) for(u32 j=0; j<n; ++j)
{ {
skipping to change at line 189 skipping to change at line 193
//! Optional argument 'side' specifies which eigenvectors should be compute d: //! Optional argument 'side' specifies which eigenvectors should be compute d:
//! 'r' for right (default) and 'l' for left. //! 'r' for right (default) and 'l' for left.
template<typename T, typename T1> template<typename T, typename T1>
inline inline
void void
eig_gen eig_gen
( (
Col< std::complex<T> >& eigval, Col< std::complex<T> >& eigval,
Mat< std::complex<T> >& eigvec, Mat< std::complex<T> >& eigvec,
const Base<std::complex<T>, T1>& X, const Base<std::complex<T>, T1>& X,
const char side = 'r' const char side = 'r',
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//std::cout << "complex" << std::endl; //std::cout << "complex" << std::endl;
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
 End of changes. 7 change blocks. 
6 lines changed or deleted 15 lines changed or added


 fn_inv.hpp   fn_inv.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_inv //! \addtogroup fn_inv
//! @{ //! @{
//! delayed matrix inverse //! delayed matrix inverse
template<typename T1> template<typename T1>
arma_inline arma_inline
const Op<T1, op_inv> const Op<T1, op_inv>
inv(const Base<typename T1::elem_type,T1>& X) inv(const Base<typename T1::elem_type,T1>& X, const typename arma_blas_type _only<typename T1::elem_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_inv>(X.get_ref()); return Op<T1, op_inv>(X.get_ref());
} }
//! remove the inverse operation if applied twice consecutively //! remove the inverse operation if applied twice consecutively
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_log_det.hpp   fn_log_det.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_log_det //! \addtogroup fn_log_det
//! @{ //! @{
//! log determinant of mat //! log determinant of mat
template<typename T1> template<typename T1>
inline inline
void void
log_det(typename T1::elem_type& out_val, typename T1::pod_type& out_sign, c log_det
onst Base<typename T1::elem_type,T1>& X) (
typename T1::elem_type& out_val,
typename T1::pod_type& out_sign,
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( !A.is_square(), "log_det(): matrix must be square" ); arma_debug_check( !A.is_square(), "log_det(): matrix must be square" );
auxlib::log_det(out_val, out_sign, A); auxlib::log_det(out_val, out_sign, A);
} }
template<typename T1> template<typename T1>
inline inline
void void
log_det(typename T1::elem_type& out_val, typename T1::pod_type& out_sign, c log_det
onst Op<T1,op_diagmat>& X) (
typename T1::elem_type& out_val,
typename T1::pod_type& out_sign,
const Op<T1,op_diagmat>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const diagmat_proxy<T1> A(X.m); const diagmat_proxy<T1> A(X.m);
const u32 N = A.n_elem; const u32 N = A.n_elem;
 End of changes. 2 change blocks. 
4 lines changed or deleted 16 lines changed or added


 fn_lu.hpp   fn_lu.hpp 
skipping to change at line 27 skipping to change at line 27
//! @{ //! @{
//! immediate lower upper decomposition //! immediate lower upper decomposition
template<typename T1> template<typename T1>
inline inline
void void
lu lu
( (
Mat<typename T1::elem_type>& L, Mat<typename T1::elem_type>& L,
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check( (&L == &U), "lu(): L and U are the same object"); arma_debug_check( (&L == &U), "lu(): L and U are the same object");
const unwrap_check<T1> tmp1(X.get_ref(), L); const unwrap_check<T1> tmp1(X.get_ref(), L);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
skipping to change at line 54 skipping to change at line 55
//! immediate lower upper decomposition, also providing the permutation mat rix //! immediate lower upper decomposition, also providing the permutation mat rix
template<typename T1> template<typename T1>
inline inline
void void
lu lu
( (
Mat<typename T1::elem_type>& L, Mat<typename T1::elem_type>& L,
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Mat<typename T1::elem_type>& P, Mat<typename T1::elem_type>& P,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check( ( (&L == &U) || (&L == &P) || (&U == &P) ), "lu(): two or more output objects are the same object"); arma_debug_check( ( (&L == &U) || (&L == &P) || (&U == &P) ), "lu(): two or more output objects are the same object");
const unwrap_check<T1> tmp1(X.get_ref(), L); const unwrap_check<T1> tmp1(X.get_ref(), L);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
 End of changes. 2 change blocks. 
2 lines changed or deleted 6 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 30 skipping to change at line 30
//! Generate a vector with 'num' elements. //! Generate a vector with 'num' elements.
//! The values of the elements linearly increase from 'start' upto (and inc luding) 'end'. //! The values of the elements linearly increase from 'start' upto (and inc luding) 'end'.
template<typename vec_type> template<typename vec_type>
inline inline
vec_type vec_type
linspace linspace
( (
const typename vec_type::pod_type start, const typename vec_type::pod_type start,
const typename vec_type::pod_type end, const typename vec_type::pod_type end,
const u32 num, const u32 num
const u32 dim = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Mat<vec_type>::value == false) >::apply(); arma_type_check< (is_Mat<vec_type>::value == false) >::apply();
arma_debug_check( (num < 2), "linspace(): num must be >= 2"); arma_debug_check( (num < 2), "linspace(): num must be >= 2");
arma_warn( (dim != 0), "linspace(): the 'dim' argument is deprecated -- p
lease use template based specification instead" );
typedef typename vec_type::elem_type eT; typedef typename vec_type::elem_type eT;
typedef typename vec_type::pod_type T; typedef typename vec_type::pod_type T;
// // this will be the default in the future: const u32 n_rows = (is_Row<vec_type>::value == true) ? 1 : num;
// const u32 n_rows = (is_Row<vec_type>::value == true) ? 1 : num; const u32 n_cols = (is_Row<vec_type>::value == true) ? num : 1;
// const u32 n_cols = (is_Row<vec_type>::value == true) ? num : 1;
// for temporary compatibility with old user code:
const u32 n_rows = (is_Row<vec_type>::value == true) ? 1 : ( (dim == 0)
? num : 1 );
const u32 n_cols = (is_Row<vec_type>::value == true) ? num : ( (dim == 0)
? 1 : num );
const eT delta = (end-start)/T(num-1);
Mat<eT> x(n_rows, n_cols); Mat<eT> x(n_rows, n_cols);
eT* x_mem = x.memptr(); eT* x_mem = x.memptr();
x_mem[0] = start; const u32 num_m1 = num - 1;
for(u32 i=1; i<num; ++i) if(is_non_integral<T>::value == true)
{ {
x_mem[i] = x_mem[i-1] + delta; const T delta = (end-start)/T(num_m1);
for(u32 i=0; i<num_m1; ++i)
{
x_mem[i] = eT(start + i*delta);
}
x_mem[num_m1] = eT(end);
}
else
{
const double delta = (end >= start) ? double(end-start)/double(num_m1)
: -double(start-end)/double(num_m1);
for(u32 i=0; i<num_m1; ++i)
{
x_mem[i] = eT(double(start) + i*delta);
}
x_mem[num_m1] = eT(end);
} }
return x; return x;
} }
inline inline
mat mat
linspace(const double start, const double end, const u32 num, const u32 dim = 0) linspace(const double start, const double end, const u32 num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return linspace<mat>(start, end, num, dim); return linspace<mat>(start, end, num);
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
const mtOp<u32, T1, op_find> const mtOp<u32, T1, op_find>
find(const Base<eT,T1>& X, const u32 k = 0, const char* direction = "first" ) find(const Base<eT,T1>& X, const u32 k = 0, const char* direction = "first" )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const char sig = direction[0]; const char sig = direction[0];
skipping to change at line 213 skipping to change at line 221
} }
return out; return out;
} }
// //
// log_add // log_add
template<typename eT> template<typename eT>
inline inline
eT typename arma_float_only<eT>::result
log_add(eT log_a, eT log_b) log_add(eT log_a, eT log_b)
{ {
if(log_a < log_b) if(log_a < log_b)
{ {
std::swap(log_a, log_b); std::swap(log_a, log_b);
} }
const eT negdelta = log_b - log_a; const eT negdelta = log_b - log_a;
if( (negdelta < Math<eT>::log_min()) || (arma_isfinite(negdelta) == false ) ) if( (negdelta < Math<eT>::log_min()) || (arma_isfinite(negdelta) == false ) )
skipping to change at line 261 skipping to change at line 269
arma_inline arma_inline
const eOpCube<T1, eop_cube_log> const eOpCube<T1, eop_cube_log>
log(const BaseCube<typename T1::elem_type,T1>& A) log(const BaseCube<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<T1, eop_cube_log>(A.get_ref()); return eOpCube<T1, eop_cube_log>(A.get_ref());
} }
// //
// trunc_log
template<typename T1>
arma_inline
const eOp<T1, eop_trunc_log>
trunc_log(const Base<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return eOp<T1, eop_trunc_log>(A.get_ref());
}
template<typename T1>
arma_inline
const eOpCube<T1, eop_cube_trunc_log>
trunc_log(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return eOpCube<T1, eop_cube_trunc_log>(A.get_ref());
}
//
// log10 // log10
template<typename T1> template<typename T1>
arma_inline arma_inline
const eOp<T1, eop_log10> const eOp<T1, eop_log10>
log10(const Base<typename T1::elem_type,T1>& A) log10(const Base<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<T1, eop_log10>(A.get_ref()); return eOp<T1, eop_log10>(A.get_ref());
skipping to change at line 330 skipping to change at line 315
arma_inline arma_inline
const eOpCube<T1, eop_cube_exp> const eOpCube<T1, eop_cube_exp>
exp(const BaseCube<typename T1::elem_type,T1>& A) exp(const BaseCube<typename T1::elem_type,T1>& A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<T1, eop_cube_exp>(A.get_ref()); return eOpCube<T1, eop_cube_exp>(A.get_ref());
} }
// //
// trunc_exp
template<typename T1>
arma_inline
const eOp<T1, eop_trunc_exp>
trunc_exp(const Base<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return eOp<T1, eop_trunc_exp>(A.get_ref());
}
template<typename T1>
arma_inline
const eOpCube<T1, eop_cube_trunc_exp>
trunc_exp(const BaseCube<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return eOpCube<T1, eop_cube_trunc_exp>(A.get_ref());
}
//
// abs // abs
template<typename T1> template<typename T1>
arma_inline arma_inline
const eOp<T1, eop_abs> const eOp<T1, eop_abs>
abs(const Base<typename T1::elem_type,T1>& X) abs(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<T1, eop_abs>(X.get_ref()); return eOp<T1, eop_abs>(X.get_ref());
 End of changes. 11 change blocks. 
68 lines changed or deleted 28 lines changed or added


 fn_ones.hpp   fn_ones.hpp 
skipping to change at line 19 skipping to change at line 19
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_ones //! \addtogroup fn_ones
//! @{ //! @{
//! Delayed generation of a dense matrix with all elements set to one //! Generate a vector with all elements set to one
arma_inline arma_inline
const eOp<mat, eop_ones_full> const eOp<colvec, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols) ones(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk =
0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_full>(n_rows, n_cols); return eOp<colvec, eop_ones_full>(n_elem, 1);
} }
template<typename vec_type>
arma_inline arma_inline
const eOpCube<cube, eop_cube_ones_full> const eOp<vec_type, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices) ones(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::resu
lt* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_ones_full>(n_rows, n_cols, n_slices); if(is_Row<vec_type>::value == true)
{
return eOp<vec_type, eop_ones_full>(1, n_elem);
}
else
{
return eOp<vec_type, eop_ones_full>(n_elem, 1);
}
} }
template<typename mat_type> //! Delayed generation of a dense matrix with all elements set to one
arma_inline arma_inline
const eOp<mat_type, eop_ones_full> const eOp<mat, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols) ones(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>::
result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<mat_type>::value == false>::apply(); return eOp<mat, eop_ones_full>(n_rows, n_cols);
return eOp<mat_type, eop_ones_full>(n_rows, n_cols);
} }
template<typename cube_type> template<typename mat_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_ones_full> const eOp<mat_type, eop_ones_full>
ones(const u32 n_rows, const u32 n_cols, const u32 n_slices) ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_on
ly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Cube<cube_type>::value == false>::apply(); arma_type_check<is_Mat<mat_type>::value == false>::apply();
return eOpCube<cube_type, eop_cube_ones_full>(n_rows, n_cols, n_slices); return eOp<mat_type, eop_ones_full>(n_rows, n_cols);
} }
//! Generate a vector with all elements set to one
arma_inline arma_inline
const eOp<colvec, eop_ones_full> const eOpCube<cube, eop_cube_ones_full>
ones(const u32 n_elem) ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cub
e_only<cube>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_ones_full>(n_elem, 1); return eOpCube<cube, eop_cube_ones_full>(n_rows, n_cols, n_slices);
} }
template<typename vec_type> template<typename cube_type>
arma_inline arma_inline
const eOp<vec_type, eop_ones_full> const eOpCube<cube_type, eop_cube_ones_full>
ones(const u32 n_elem) ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename
arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply(); arma_type_check<is_Cube<cube_type>::value == false>::apply();
if(is_Row<vec_type>::value == true) return eOpCube<cube_type, eop_cube_ones_full>(n_rows, n_cols, n_slices);
{
return eOp<vec_type, eop_ones_full>(1, n_elem);
}
else
{
return eOp<vec_type, eop_ones_full>(n_elem, 1);
}
} }
//! Delayed generation of a diagonal matrix with the diagonal elements set to one //! Delayed generation of a diagonal matrix with the diagonal elements set to one
arma_inline arma_inline
const eOp<mat, eop_ones_diag> const eOp<mat, eop_ones_diag>
eye(const u32 n_rows, const u32 n_cols) eye(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>::r esult* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_ones_diag>(n_rows, n_cols); return eOp<mat, eop_ones_diag>(n_rows, n_cols);
} }
template<typename mat_type> template<typename mat_type>
arma_inline arma_inline
const eOp<mat_type, eop_ones_diag> const eOp<mat_type, eop_ones_diag>
eye(const u32 n_rows, const u32 n_cols) eye(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_onl y<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat_only<mat_type>::value == false>::apply(); arma_type_check<is_Mat_only<mat_type>::value == false>::apply();
return eOp<mat_type, eop_ones_diag>(n_rows, n_cols); return eOp<mat_type, eop_ones_diag>(n_rows, n_cols);
} }
//! @} //! @}
 End of changes. 22 change blocks. 
36 lines changed or deleted 40 lines changed or added


 fn_pinv.hpp   fn_pinv.hpp 
skipping to change at line 23 skipping to change at line 23
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_pinv //! \addtogroup fn_pinv
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pinv> const Op<T1, op_pinv>
pinv(const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type pinv
tol = 0.0) (
const Base<typename T1::elem_type,T1>& X,
const typename T1::elem_type tol = 0.0,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_pinv>(X.get_ref(), tol); return Op<T1, op_pinv>(X.get_ref(), tol);
} }
//! @} //! @}
 End of changes. 1 change blocks. 
2 lines changed or deleted 7 lines changed or added


 fn_princomp.hpp   fn_princomp.hpp 
skipping to change at line 35 skipping to change at line 35
//! tsquared_out -> Hotelling's T^2 statistic //! tsquared_out -> Hotelling's T^2 statistic
template<typename T1> template<typename T1>
inline inline
void void
princomp princomp
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<typename T1::elem_type>& score_out, Mat<typename T1::elem_type>& score_out,
Col<typename T1::pod_type>& latent_out, Col<typename T1::pod_type>& latent_out,
Col<typename T1::elem_type>& tsquared_out, Col<typename T1::elem_type>& tsquared_out,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_princomp::direct_princomp(coeff_out, score_out, latent_out, tsquared_o ut, A); op_princomp::direct_princomp(coeff_out, score_out, latent_out, tsquared_o ut, A);
skipping to change at line 61 skipping to change at line 62
//! score_out -> projected samples //! score_out -> projected samples
//! latent_out -> eigenvalues of principal vectors //! latent_out -> eigenvalues of principal vectors
template<typename T1> template<typename T1>
inline inline
void void
princomp princomp
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<typename T1::elem_type>& score_out, Mat<typename T1::elem_type>& score_out,
Col<typename T1::pod_type>& latent_out, Col<typename T1::pod_type>& latent_out,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_princomp::direct_princomp(coeff_out, score_out, latent_out, A); op_princomp::direct_princomp(coeff_out, score_out, latent_out, A);
skipping to change at line 85 skipping to change at line 87
//! principal component analysis -- 2 arguments version //! principal component analysis -- 2 arguments version
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! score_out -> projected samples //! score_out -> projected samples
template<typename T1> template<typename T1>
inline inline
void void
princomp princomp
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Mat<typename T1::elem_type>& score_out, Mat<typename T1::elem_type>& score_out,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_princomp::direct_princomp(coeff_out, score_out, A); op_princomp::direct_princomp(coeff_out, score_out, A);
} }
//! \brief //! \brief
//! principal component analysis -- 1 argument version //! principal component analysis -- 1 argument version
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_princomp> const Op<T1, op_princomp>
princomp(const Base<typename T1::elem_type,T1>& X) princomp
(
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_princomp>(X.get_ref()); return Op<T1, op_princomp>(X.get_ref());
} }
//! @} //! @}
 End of changes. 4 change blocks. 
4 lines changed or deleted 15 lines changed or added


 fn_princomp_cov.hpp   fn_princomp_cov.hpp 
skipping to change at line 33 skipping to change at line 33
//! latent_out -> principal component variances //! latent_out -> principal component variances
//! explained_out -> percentage of the total variance explained by each pri ncipal component. //! explained_out -> percentage of the total variance explained by each pri ncipal component.
template<typename T1> template<typename T1>
inline inline
void void
princomp_cov princomp_cov
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Col<typename T1::pod_type>& latent_out, Col<typename T1::pod_type>& latent_out,
Col<typename T1::pod_type>& explained_out, Col<typename T1::pod_type>& explained_out,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_princomp_cov::direct_princomp_cov(coeff_out, latent_out, explained_out , A); op_princomp_cov::direct_princomp_cov(coeff_out, latent_out, explained_out , A);
skipping to change at line 57 skipping to change at line 58
//! principal component analysis of a covariance matrix -- 2 arguments vers ion //! principal component analysis of a covariance matrix -- 2 arguments vers ion
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
//! latent_out -> principal component variances //! latent_out -> principal component variances
template<typename T1> template<typename T1>
inline inline
void void
princomp_cov princomp_cov
( (
Mat<typename T1::elem_type>& coeff_out, Mat<typename T1::elem_type>& coeff_out,
Col<typename T1::pod_type>& latent_out, Col<typename T1::pod_type>& latent_out,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
op_princomp_cov::direct_princomp_cov(coeff_out, latent_out, A); op_princomp_cov::direct_princomp_cov(coeff_out, latent_out, A);
} }
//! \brief //! \brief
//! principal component analysis of a covariance matrix -- 1 argument versi on //! principal component analysis of a covariance matrix -- 1 argument versi on
//! coeff_out -> principal component coefficients //! coeff_out -> principal component coefficients
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_princomp_cov> const Op<T1, op_princomp_cov>
princomp_cov(const Base<typename T1::elem_type,T1>& X) princomp_cov
(
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_princomp_cov>(X.get_ref()); return Op<T1, op_princomp_cov>(X.get_ref());
} }
//! @} //! @}
 End of changes. 3 change blocks. 
3 lines changed or deleted 12 lines changed or added


 fn_qr.hpp   fn_qr.hpp 
skipping to change at line 23 skipping to change at line 23
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_qr //! \addtogroup fn_qr
//! @{ //! @{
//! QR decomposition //! QR decomposition
template<typename T1> template<typename T1>
inline inline
void void
qr(Mat<typename T1::elem_type>& Q, Mat<typename T1::elem_type>& R, const Ba qr
se<typename T1::elem_type,T1>& X) (
Mat<typename T1::elem_type>& Q,
Mat<typename T1::elem_type>& R,
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check( (&Q == &R), "qr(): Q and R are the same object"); arma_debug_check( (&Q == &R), "qr(): Q and R are the same object");
const unwrap_check<T1> tmp1(X.get_ref(), Q); const unwrap_check<T1> tmp1(X.get_ref(), Q);
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
 End of changes. 1 change blocks. 
2 lines changed or deleted 8 lines changed or added


 fn_randn.hpp   fn_randn.hpp 
skipping to change at line 19 skipping to change at line 19
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_randn //! \addtogroup fn_randn
//! @{ //! @{
//! Generate a dense matrix with all elements set to random values with a g inline
aussian distribution (zero mean, unit variance) double
randn()
{
return double(eop_aux_randn<double>());
}
template<typename eT>
inline
typename arma_scalar_only<eT>::result
randn()
{
return eT(eop_aux_randn<eT>());
}
//! Generate a vector with all elements set to random values with a gaussia
n distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<mat, eop_randn> const eOp<colvec, eop_randn>
randn(const u32 n_rows, const u32 n_cols) randn(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk =
0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_randn>(n_rows, n_cols); return eOp<colvec, eop_randn>(n_elem, 1);
} }
template<typename vec_type>
arma_inline arma_inline
const eOpCube<cube, eop_cube_randn> const eOp<vec_type, eop_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices) randn(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res
ult* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_randn>(n_rows, n_cols, n_slices); if(is_Row<vec_type>::value == true)
{
return eOp<vec_type, eop_randn>(1, n_elem);
}
else
{
return eOp<vec_type, eop_randn>(n_elem, 1);
}
} }
template<typename mat_type> //! Generate a dense matrix with all elements set to random values with a g aussian distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<mat_type, eop_randn> const eOp<mat, eop_randn>
randn(const u32 n_rows, const u32 n_cols) randn(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>:
:result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<mat_type>::value == false>::apply(); return eOp<mat, eop_randn>(n_rows, n_cols);
return eOp<mat_type, eop_randn>(n_rows, n_cols);
} }
template<typename cube_type> template<typename mat_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_randn> const eOp<mat_type, eop_randn>
randn(const u32 n_rows, const u32 n_cols, const u32 n_slices) randn(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o
nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Cube<cube_type>::value == false>::apply(); return eOp<mat_type, eop_randn>(n_rows, n_cols);
return eOpCube<cube_type, eop_cube_randn>(n_rows, n_cols, n_slices);
} }
//! Generate a vector with all elements set to random values with a gaussia n distribution (zero mean, unit variance)
arma_inline arma_inline
const eOp<colvec, eop_randn> const eOpCube<cube, eop_cube_randn>
randn(const u32 n_elem) randn(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cu
be_only<cube>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_randn>(n_elem, 1); return eOpCube<cube, eop_cube_randn>(n_rows, n_cols, n_slices);
} }
template<typename vec_type> template<typename cube_type>
arma_inline arma_inline
const eOp<vec_type, eop_randn> const eOpCube<cube_type, eop_cube_randn>
randn(const u32 n_elem) randn(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam
e arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: return eOpCube<cube_type, eop_cube_randn>(n_rows, n_cols, n_slices);
:value == false) >::apply();
if(is_Row<vec_type>::value == true)
{
return eOp<vec_type, eop_randn>(1, n_elem);
}
else
{
return eOp<vec_type, eop_randn>(n_elem, 1);
}
} }
//! @} //! @}
 End of changes. 18 change blocks. 
38 lines changed or deleted 52 lines changed or added


 fn_rank.hpp   fn_rank.hpp 
skipping to change at line 24 skipping to change at line 24
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_rank //! \addtogroup fn_rank
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
u32 u32
rank(const Base<typename T1::elem_type,T1>& X, typename T1::pod_type tol = rank
0.0) (
const Base<typename T1::elem_type,T1>& X,
typename T1::pod_type tol = 0.0,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
Col<T> s; Col<T> s;
 End of changes. 1 change blocks. 
2 lines changed or deleted 7 lines changed or added


 fn_solve.hpp   fn_solve.hpp 
skipping to change at line 30 skipping to change at line 30
//! For a square matrix A, this function is conceptually the same as X = in v(A)*B, //! For a square matrix A, this function is conceptually the same as X = in v(A)*B,
//! but is done more efficiently. //! but is done more efficiently.
//! The number of rows in A and B must be the same. //! The number of rows in A and B must be the same.
//! B can be either a column vector or a matrix. //! B can be either a column vector or a matrix.
//! This function will also try to provide approximate solutions //! This function will also try to provide approximate solutions
//! to under-determined as well as over-determined systems (non-square A ma trices). //! to under-determined as well as over-determined systems (non-square A ma trices).
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
const Glue<T1, T2, glue_solve> const Glue<T1, T2, glue_solve>
solve(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::ele solve
m_type,T2>& B) (
const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Glue<T1, T2, glue_solve>(A.get_ref(), B.get_ref()); return Glue<T1, T2, glue_solve>(A.get_ref(), B.get_ref());
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
bool bool
solve(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type,T solve
1>& A, const Base<typename T1::elem_type,T2>& B) (
Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& A,
const Base<typename T1::elem_type,T2>& B,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = solve(A,B); out = solve(A,B);
return (out.n_elem == 0) ? false : true; return (out.n_elem == 0) ? false : true;
} }
//! @} //! @}
 End of changes. 2 change blocks. 
4 lines changed or deleted 15 lines changed or added


 fn_svd.hpp   fn_svd.hpp 
skipping to change at line 22 skipping to change at line 22
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_svd //! \addtogroup fn_svd
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
bool bool
svd(Col<typename T1::pod_type>& S, const Base<typename T1::elem_type,T1>& X svd
) (
Col<typename T1::pod_type>& S,
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// unwrap_check not used as T1::elem_type and T1::pod_type may not be the same. // unwrap_check not used as T1::elem_type and T1::pod_type may not be the same.
// furthermore, it doesn't matter if A is an alias of S, as auxlib::svd() makes a copy of A // furthermore, it doesn't matter if A is an alias of S, as auxlib::svd() makes a copy of A
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
skipping to change at line 47 skipping to change at line 52
{ {
arma_print("svd(): singular value decomposition failed"); arma_print("svd(): singular value decomposition failed");
} }
return status; return status;
} }
template<typename T1> template<typename T1>
inline inline
Col<typename T1::pod_type> Col<typename T1::pod_type>
svd(const Base<typename T1::elem_type,T1>& X) svd
(
const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Col<typename T1::pod_type> out; Col<typename T1::pod_type> out;
const bool status = svd(out, X); const bool status = svd(out, X);
if(status == false) if(status == false)
{ {
out.set_size(0); out.set_size(0);
skipping to change at line 71 skipping to change at line 80
} }
template<typename T1> template<typename T1>
inline inline
bool bool
svd svd
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type>& S, Col<typename T1::pod_type>& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
arma_debug_check( ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void* )(&S) == (void*)(&V)) ), "svd(): two or more output objects are the same ob ject" ); arma_debug_check( ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void* )(&S) == (void*)(&V)) ), "svd(): two or more output objects are the same ob ject" );
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
 End of changes. 3 change blocks. 
4 lines changed or deleted 16 lines changed or added


 fn_trace.hpp   fn_trace.hpp 
skipping to change at line 32 skipping to change at line 32
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
trace(const Base<typename T1::elem_type,T1>& X) trace(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
arma_debug_check( (A.n_rows != A.n_cols), "trace(): matrix must be square " ); arma_debug_check( (A.n_rows != A.n_cols), "trace(): matrix must be square sized" );
eT val = eT(0); const u32 N = A.n_rows;
eT val = eT(0);
for(u32 i=0; i<A.n_rows; ++i) for(u32 i=0; i<N; ++i)
{ {
val += A.at(i,i); val += A.at(i,i);
} }
return val; return val;
} }
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
skipping to change at line 68 skipping to change at line 69
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<N; ++i) for(u32 i=0; i<N; ++i)
{ {
val += A[i]; val += A[i];
} }
return val; return val;
} }
//! speedup for trace(A*B), where the result of A*B is a square sized matri
x
template<typename T1, typename T2>
inline
arma_warn_unused
typename T1::elem_type
trace(const Glue<T1, T2, glue_times>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X.A);
const unwrap<T2> tmp2(X.B);
const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M;
arma_debug_assert_mul_size(A, B, "matrix multiply");
arma_debug_check( (A.n_rows != B.n_cols), "trace(): matrix must be square
sized" );
const u32 N1 = A.n_rows;
const u32 N2 = A.n_cols;
eT val = eT(0);
for(u32 i=0; i<N1; ++i)
{
const eT* B_colmem = B.colptr(i);
eT acc = eT(0);
for(u32 j=0; j<N2; ++j)
{
acc += A.at(i,j) * B_colmem[j];
}
val += acc;
}
return val;
}
//! @} //! @}
 End of changes. 4 change blocks. 
3 lines changed or deleted 47 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
skipping to change at line 19 skipping to change at line 19
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup fn_zeros //! \addtogroup fn_zeros
//! @{ //! @{
//! Generate a dense matrix with all elements set to zero //! Generate a vector with all elements set to zero
arma_inline arma_inline
const eOp<mat, eop_zeros> const eOp<colvec, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols) zeros(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk =
0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<mat, eop_zeros>(n_rows, n_cols); return eOp<colvec, eop_zeros>(n_elem, 1);
} }
template<typename vec_type>
arma_inline arma_inline
const eOpCube<cube, eop_cube_zeros> const eOp<vec_type, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices) zeros(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::res
ult* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOpCube<cube, eop_cube_zeros>(n_rows, n_cols, n_slices); if(is_Row<vec_type>::value == true)
{
return eOp<vec_type, eop_zeros>(1, n_elem);
}
else
{
return eOp<vec_type, eop_zeros>(n_elem, 1);
}
} }
template<typename mat_type> //! Generate a dense matrix with all elements set to zero
arma_inline arma_inline
const eOp<mat_type, eop_zeros> const eOp<mat, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols) zeros(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>:
:result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Mat<mat_type>::value == false>::apply(); return eOp<mat, eop_zeros>(n_rows, n_cols);
return eOp<mat_type, eop_zeros>(n_rows, n_cols);
} }
template<typename cube_type> template<typename mat_type>
arma_inline arma_inline
const eOpCube<cube_type, eop_cube_zeros> const eOp<mat_type, eop_zeros>
zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices) zeros(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_o
nly<mat_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check<is_Cube<cube_type>::value == false>::apply(); arma_type_check<is_Mat<mat_type>::value == false>::apply();
return eOpCube<cube_type, eop_cube_zeros>(n_rows, n_cols, n_slices); return eOp<mat_type, eop_zeros>(n_rows, n_cols);
} }
//! Generate a vector with all elements set to zero
arma_inline arma_inline
const eOp<colvec, eop_zeros> const eOpCube<cube, eop_cube_zeros>
zeros(const u32 n_elem) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cu
be_only<cube>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return eOp<colvec, eop_zeros>(n_elem, 1); return eOpCube<cube, eop_cube_zeros>(n_rows, n_cols, n_slices);
} }
template<typename vec_type> template<typename cube_type>
arma_inline arma_inline
const eOp<vec_type, eop_zeros> const eOpCube<cube_type, eop_cube_zeros>
zeros(const u32 n_elem) zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typenam
e arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>: :value == false) >::apply(); arma_type_check<is_Cube<cube_type>::value == false>::apply();
if(is_Row<vec_type>::value == true) return eOpCube<cube_type, eop_cube_zeros>(n_rows, n_cols, n_slices);
{
return eOp<vec_type, eop_zeros>(1, n_elem);
}
else
{
return eOp<vec_type, eop_zeros>(n_elem, 1);
}
} }
//! @} //! @}
 End of changes. 20 change blocks. 
34 lines changed or deleted 38 lines changed or added


 format_wrap.hpp   format_wrap.hpp 
skipping to change at line 465 skipping to change at line 465
inline inline
std::ostream& std::ostream&
operator<< (std::ostream& o, const basic_format<T1,T2>& X) operator<< (std::ostream& o, const basic_format<T1,T2>& X)
{ {
o << str(X); o << str(X);
return o; return o;
} }
#endif #endif
template<typename T> struct string_only { };
template<> struct string_only<std::string> { typedef std::strin
g result; };
template<typename T> struct char_only { };
template<> struct char_only<char > { typedef char
result; };
template<typename T>
struct basic_format_only { };
#if defined(ARMA_USE_BOOST_FORMAT)
template<typename T>
struct basic_format_only< basic_format<T> > { typedef basic_format
<T> result; };
#else
template<typename T1, typename T2>
struct basic_format_only< basic_format<T1, T2> > { typedef basic_format
<T1,T2> result; };
#endif
template<typename T1>
inline
static
const T1&
str_wrapper(const T1& x, const typename string_only<T1>::result* junk = 0
)
{
return x;
}
template<typename T1>
inline
static
const T1*
str_wrapper(const T1* x, const typename char_only<T1>::result* junk = 0)
{
return x;
}
template<typename T1>
inline
static
std::string
str_wrapper(const T1& x, const typename basic_format_only<T1>::result* ju
nk = 0)
{
return str(x);
}
} }
//! @} //! @}
 End of changes. 1 change blocks. 
0 lines changed or deleted 50 lines changed or added


 glue_join_meat.hpp   glue_join_meat.hpp 
skipping to change at line 36 skipping to change at line 36
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> A_tmp(X.A); const unwrap<T1> A_tmp(X.A);
const unwrap<T2> B_tmp(X.B); const unwrap<T2> B_tmp(X.B);
const Mat<eT>& A = A_tmp.M; const Mat<eT>& A = A_tmp.M;
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
const u32 join_type = X.aux_u32; const u32 join_type = X.aux_u32;
if(A.n_elem == 0)
{
out = B;
return;
}
if(B.n_elem == 0)
{
out = A;
return;
}
if(join_type == 0) if(join_type == 0)
{ {
arma_debug_check( (A.n_cols != B.n_cols), "join_cols(): number of colum ns must be the same" ); arma_debug_check( (A.n_cols != B.n_cols), "join_cols(): number of colum ns must be the same" );
} }
else else
{ {
arma_debug_check( (A.n_rows != B.n_rows), "join_rows(): number of rows must be the same" ); arma_debug_check( (A.n_rows != B.n_rows), "join_rows(): number of rows must be the same" );
} }
if( (&out != &A) && (&out != &B) ) if( (&out != &A) && (&out != &B) )
 End of changes. 1 change blocks. 
0 lines changed or deleted 12 lines changed or added


 itpp_wrap.hpp   itpp_wrap.hpp 
skipping to change at line 29 skipping to change at line 29
#ifdef ARMA_USE_ITPP #ifdef ARMA_USE_ITPP
#include <itpp/base/mat.h> #include <itpp/base/mat.h>
#include <itpp/base/vec.h> #include <itpp/base/vec.h>
#else #else
namespace itpp namespace itpp
{ {
//! dummy itpp::Mat class, to prevent compilation errors
template<typename eT> template<typename eT>
class Mat class Mat
{ {
public: public:
int rows() const { return 0; } ~Mat() {}
int cols() const { return 0; } Mat() {}
int size() const { return 0; } Mat(int n_rows, int n_cols) {}
Mat(const Mat& m) {}
const Mat& operator=(const Mat& m) { return *this; }
int rows() const { return 0; }
int cols() const { return 0; }
int size() const { return 0; }
const eT* _data() const { return 0; } const eT* _data() const { return 0; }
eT* _data() { return 0; } eT* _data() { return 0; }
};
private:
Mat();
Mat(const Mat& m);
const Mat& operator=(const Mat& m);
~Mat();
};
//! dummy itpp::Vec class, to prevent compilation errors
template<typename eT> template<typename eT>
class Vec class Vec
{ {
public: public:
int size() const { return 0; } ~Vec() {}
int length() const { return 0; } Vec() {}
const eT* _data() const { return 0; } Vec(int length) {}
eT* _data() { return 0; } Vec(const Vec& m) {}
private: const Vec& operator=(const Vec& m) { return *this; }
Vec(); int size() const { return 0; }
Vec(const Vec& m); int length() const { return 0; }
const Vec& operator=(const Vec& m); const eT* _data() const { return 0; }
~Vec(); eT* _data() { return 0; }
}; };
typedef Mat<short int> smat; typedef Mat<short int> smat;
typedef Vec<short int> svec; typedef Vec<short int> svec;
typedef Mat<int> imat; typedef Mat<int> imat;
typedef Vec<int> ivec; typedef Vec<int> ivec;
typedef Mat<double> mat; typedef Mat<double> mat;
typedef Vec<double> vec; typedef Vec<double> vec;
 End of changes. 5 change blocks. 
23 lines changed or deleted 25 lines changed or added


 op_dot_meat.hpp   op_dot_meat.hpp 
skipping to change at line 19 skipping to change at line 19
// for any purpose. You can redistribute this file // for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU // and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published // Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3 // by the Free Software Foundation, either version 3
// of the License or (at your option) any later version. // of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info) // (see http://www.opensource.org/licenses for more info)
//! \addtogroup op_dot //! \addtogroup op_dot
//! @{ //! @{
//! for two arrays //! for two arrays, generic version
template<typename eT> template<typename eT>
inline
arma_hot arma_hot
arma_pure arma_pure
inline
eT eT
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B) op_dot::direct_dot_arma(const u32 n_elem, const eT* const A, const eT* cons t B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val1 = eT(0); eT val1 = eT(0);
eT val2 = eT(0); eT val2 = eT(0);
u32 i,j; u32 i, j;
for(i=0, j=1; j<n_elem; i+=2, j+=2) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
val1 += A[i] * B[i]; val1 += A[i] * B[i];
val2 += A[j] * B[j]; val2 += A[j] * B[j];
} }
if(i < n_elem) if(i < n_elem)
{ {
val1 += A[i] * B[i]; val1 += A[i] * B[i];
} }
return val1+val2; return val1 + val2;
} }
//! for three arrays //! for two arrays, float and double version
template<typename eT>
arma_hot
arma_pure
inline
typename arma_float_only<eT>::result
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B)
{
arma_extra_debug_sigprint();
if( n_elem <= (128/sizeof(eT)) )
{
return op_dot::direct_dot_arma(n_elem, A, B);
}
else
{
#if defined(ARMA_USE_ATLAS)
{
return atlas::cblas_dot(n_elem, A, B);
}
#elif defined(ARMA_USE_BLAS)
{
const int n = n_elem;
return blas::dot_(&n, A, B);
}
#else
{
return op_dot::direct_dot_arma(n_elem, A, B);
}
#endif
}
}
//! for two arrays, complex version
template<typename eT> template<typename eT>
inline inline
arma_hot arma_hot
arma_pure arma_pure
typename arma_cx_only<eT>::result
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B)
{
#if defined(ARMA_USE_ATLAS)
{
return atlas::cx_cblas_dot(n_elem, A, B);
}
#elif defined(ARMA_USE_BLAS)
{
// TODO: work out the mess with zdotu() and zdotu_sub() in BLAS
return op_dot::direct_dot_arma(n_elem, A, B);
}
#else
{
return op_dot::direct_dot_arma(n_elem, A, B);
}
#endif
}
//! for two arrays, integral version
template<typename eT>
arma_hot
arma_pure
inline
typename arma_integral_only<eT>::result
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B)
{
return op_dot::direct_dot_arma(n_elem, A, B);
}
//! for three arrays
template<typename eT>
arma_hot
arma_pure
inline
eT eT
op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B, const eT* C) op_dot::direct_dot(const u32 n_elem, const eT* const A, const eT* const B, const eT* C)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
eT val = eT(0); eT val = eT(0);
for(u32 i=0; i<n_elem; ++i) for(u32 i=0; i<n_elem; ++i)
{ {
val += A[i] * B[i] * C[i]; val += A[i] * B[i] * C[i];
} }
return val; return val;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline
arma_hot arma_hot
arma_inline
typename T1::elem_type typename T1::elem_type
op_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y) op_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) ) if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) )
{ {
return op_dot::apply_unwrap(X,Y); return op_dot::apply_unwrap(X,Y);
} }
else else
{ {
return op_dot::apply_proxy(X,Y); return op_dot::apply_proxy(X,Y);
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline
arma_hot arma_hot
arma_inline
typename T1::elem_type typename T1::elem_type
op_dot::apply_unwrap(const Base<typename T1::elem_type,T1>& X, const Base<t ypename T1::elem_type,T2>& Y) op_dot::apply_unwrap(const Base<typename T1::elem_type,T1>& X, const Base<t ypename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X.get_ref()); const unwrap<T1> tmp1(X.get_ref());
const unwrap<T2> tmp2(Y.get_ref()); const unwrap<T2> tmp2(Y.get_ref());
const Mat<eT>& A = tmp1.M; const Mat<eT>& A = tmp1.M;
const Mat<eT>& B = tmp2.M; const Mat<eT>& B = tmp2.M;
arma_debug_check( (A.n_elem != B.n_elem), "dot(): objects must have the s ame number of elements" ); arma_debug_check( (A.n_elem != B.n_elem), "dot(): objects must have the s ame number of elements" );
return op_dot::direct_dot(A.n_elem, A.mem, B.mem); return op_dot::direct_dot(A.n_elem, A.mem, B.mem);
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline
arma_hot arma_hot
inline
typename T1::elem_type typename T1::elem_type
op_dot::apply_proxy(const Base<typename T1::elem_type,T1>& X, const Base<ty pename T1::elem_type,T2>& Y) op_dot::apply_proxy(const Base<typename T1::elem_type,T1>& X, const Base<ty pename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
const Proxy<T2> B(Y.get_ref()); const Proxy<T2> B(Y.get_ref());
skipping to change at line 135 skipping to change at line 204
{ {
val += A[i] * B[i]; val += A[i] * B[i];
} }
return val; return val;
} }
// //
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline
arma_hot arma_hot
arma_inline
typename T1::elem_type typename T1::elem_type
op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typ ename T1::elem_type,T2>& Y) op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typ ename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) ) if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) )
{ {
return op_norm_dot::apply_unwrap(X,Y); return op_norm_dot::apply_unwrap(X,Y);
} }
else else
{ {
return op_norm_dot::apply_proxy(X,Y); return op_norm_dot::apply_proxy(X,Y);
} }
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline
arma_hot arma_hot
inline
typename T1::elem_type typename T1::elem_type
op_norm_dot::apply_unwrap(const Base<typename T1::elem_type,T1>& X, const B ase<typename T1::elem_type,T2>& Y) op_norm_dot::apply_unwrap(const Base<typename T1::elem_type,T1>& X, const B ase<typename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> tmp1(X.get_ref()); const unwrap<T1> tmp1(X.get_ref());
const unwrap<T2> tmp2(Y.get_ref()); const unwrap<T2> tmp2(Y.get_ref());
skipping to change at line 189 skipping to change at line 258
for(u32 i=0; i<N; ++i) for(u32 i=0; i<N; ++i)
{ {
const eT tmpA = A_mem[i]; const eT tmpA = A_mem[i];
const eT tmpB = B_mem[i]; const eT tmpB = B_mem[i];
acc1 += tmpA * tmpA; acc1 += tmpA * tmpA;
acc2 += tmpB * tmpB; acc2 += tmpB * tmpB;
acc3 += tmpA * tmpB; acc3 += tmpA * tmpB;
} }
return acc3 / ( std::sqrt(acc1 * acc2) ); // TODO: this only makes sens e for eT = float, double or complex return acc3 / ( std::sqrt(acc1 * acc2) );
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline
arma_hot arma_hot
inline
typename T1::elem_type typename T1::elem_type
op_norm_dot::apply_proxy(const Base<typename T1::elem_type,T1>& X, const Ba se<typename T1::elem_type,T2>& Y) op_norm_dot::apply_proxy(const Base<typename T1::elem_type,T1>& X, const Ba se<typename T1::elem_type,T2>& Y)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Proxy<T1> A(X.get_ref()); const Proxy<T1> A(X.get_ref());
const Proxy<T2> B(Y.get_ref()); const Proxy<T2> B(Y.get_ref());
skipping to change at line 223 skipping to change at line 292
for(u32 i=0; i<N; ++i) for(u32 i=0; i<N; ++i)
{ {
const eT tmpA = A[i]; const eT tmpA = A[i];
const eT tmpB = B[i]; const eT tmpB = B[i];
acc1 += tmpA * tmpA; acc1 += tmpA * tmpA;
acc2 += tmpB * tmpB; acc2 += tmpB * tmpB;
acc3 += tmpA * tmpB; acc3 += tmpA * tmpB;
} }
return acc3 / ( std::sqrt(acc1 * acc2) ); // TODO: this only makes sens e for eT = float, double or complex return acc3 / ( std::sqrt(acc1 * acc2) );
} }
//! @} //! @}
 End of changes. 22 change blocks. 
14 lines changed or deleted 83 lines changed or added


 op_dot_proto.hpp   op_dot_proto.hpp 
skipping to change at line 27 skipping to change at line 27
//! @{ //! @{
//! \brief //! \brief
//! dot product operation //! dot product operation
class op_dot class op_dot
{ {
public: public:
template<typename eT> template<typename eT>
inline arma_hot arma_pure static eT direct_dot(const u32 n_elem, const eT * const A, const eT* const B); arma_hot arma_pure inline static eT direct_dot_arma(const u32 n_elem, con st eT* const A, const eT* const B);
template<typename eT> template<typename eT>
inline arma_hot arma_pure static eT direct_dot(const u32 n_elem, const eT arma_hot arma_pure inline static typename arma_float_only<eT>::result
* const A, const eT* const B, const eT* C); direct_dot(const u32 n_elem, const eT* const A, const eT* const B);
template<typename eT>
arma_hot arma_pure inline static typename arma_cx_only<eT>::result
direct_dot(const u32 n_elem, const eT* const A, const eT* const B);
template<typename eT>
arma_hot arma_pure inline static typename arma_integral_only<eT>::result
direct_dot(const u32 n_elem, const eT* const A, const eT* const B);
template<typename eT>
arma_hot arma_pure inline static eT direct_dot(const u32 n_elem, const eT
* const A, const eT* const B, const eT* C);
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_hot static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot arma_inline static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
inline arma_hot static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
inline arma_hot static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
}; };
//! \brief //! \brief
//! normalised dot product operation //! normalised dot product operation
class op_norm_dot class op_norm_dot
{ {
public: public:
template<typename T1, typename T2> template<typename T1, typename T2>
arma_inline arma_hot static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot arma_inline static typename T1::elem_type apply(const Base<typen ame T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
inline arma_hot static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_unwrap(const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
template<typename T1, typename T2> template<typename T1, typename T2>
inline arma_hot static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y); arma_hot inline static typename T1::elem_type apply_proxy (const Base<typ ename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y);
}; };
//! @} //! @}
 End of changes. 8 change blocks. 
9 lines changed or deleted 21 lines changed or added


 restrictors.hpp   restrictors.hpp 
skipping to change at line 83 skipping to change at line 83
template<> struct arma_float_or_cx_only< double > { typedef d ouble result; }; template<> struct arma_float_or_cx_only< double > { typedef d ouble result; };
template<> struct arma_float_or_cx_only< std::complex<float> > { typedef s td::complex<float> result; }; template<> struct arma_float_or_cx_only< std::complex<float> > { typedef s td::complex<float> result; };
template<> struct arma_float_or_cx_only< std::complex<double> > { typedef s td::complex<double> result; }; template<> struct arma_float_or_cx_only< std::complex<double> > { typedef s td::complex<double> result; };
template<typename T> struct arma_cx_only { }; template<typename T> struct arma_cx_only { };
template<typename T> struct arma_cx_only< std::complex<T> > { typedef std:: complex<T> result; }; template<typename T> struct arma_cx_only< std::complex<T> > { typedef std:: complex<T> result; };
template<typename T> struct arma_not_cx { typedef T resu lt; }; template<typename T> struct arma_not_cx { typedef T resu lt; };
template<typename T> struct arma_not_cx< std::complex<T> > { }; template<typename T> struct arma_not_cx< std::complex<T> > { };
template<typename T> struct arma_blas_type_only { };
template<> struct arma_blas_type_only< float > { typedef flo
at result; };
template<> struct arma_blas_type_only< double > { typedef dou
ble result; };
template<> struct arma_blas_type_only< std::complex<float> > { typedef std
::complex<float> result; };
template<> struct arma_blas_type_only< std::complex<double> > { typedef std
::complex<double> result; };
template<typename T> struct arma_op_rel_only { }; template<typename T> struct arma_op_rel_only { };
template<> struct arma_op_rel_only< op_rel_lt_pre > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_lt_pre > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_lt_post > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_lt_post > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_gt_pre > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_gt_pre > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_gt_post > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_gt_post > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_lteq_pre > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_lteq_pre > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_lteq_post > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_lteq_post > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_gteq_pre > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_gteq_pre > { typedef int result ; };
template<> struct arma_op_rel_only< op_rel_gteq_post > { typedef int result ; }; template<> struct arma_op_rel_only< op_rel_gteq_post > { typedef int result ; };
skipping to change at line 118 skipping to change at line 125
template<typename T> struct arma_glue_rel_only { }; template<typename T> struct arma_glue_rel_only { };
template<> struct arma_glue_rel_only< glue_rel_lt > { typedef int result ; }; template<> struct arma_glue_rel_only< glue_rel_lt > { typedef int result ; };
template<> struct arma_glue_rel_only< glue_rel_gt > { typedef int result ; }; template<> struct arma_glue_rel_only< glue_rel_gt > { typedef int result ; };
template<> struct arma_glue_rel_only< glue_rel_lteq > { typedef int result ; }; template<> struct arma_glue_rel_only< glue_rel_lteq > { typedef int result ; };
template<> struct arma_glue_rel_only< glue_rel_gteq > { typedef int result ; }; template<> struct arma_glue_rel_only< glue_rel_gteq > { typedef int result ; };
template<> struct arma_glue_rel_only< glue_rel_eq > { typedef int result ; }; template<> struct arma_glue_rel_only< glue_rel_eq > { typedef int result ; };
template<> struct arma_glue_rel_only< glue_rel_noteq > { typedef int result ; }; template<> struct arma_glue_rel_only< glue_rel_noteq > { typedef int result ; };
template<typename T> struct arma_Mat_Col_Row_only { };
template<typename eT> struct arma_Mat_Col_Row_only< Mat<eT> > { typedef Mat
<eT> result; };
template<typename eT> struct arma_Mat_Col_Row_only< Col<eT> > { typedef Col
<eT> result; };
template<typename eT> struct arma_Mat_Col_Row_only< Row<eT> > { typedef Row
<eT> result; };
template<typename T> struct arma_Cube_only { };
template<typename eT> struct arma_Cube_only< Cube<eT> > { typedef Cube<eT>
result; };
//! @} //! @}
 End of changes. 2 change blocks. 
0 lines changed or deleted 24 lines changed or added


 running_stat_vec_meat.hpp   running_stat_vec_meat.hpp 
skipping to change at line 32 skipping to change at line 32
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT> template<typename eT>
running_stat_vec<eT>::running_stat_vec(const bool in_calc_cov) running_stat_vec<eT>::running_stat_vec(const bool in_calc_cov)
: calc_cov(in_calc_cov) : calc_cov(in_calc_cov)
{ {
arma_extra_debug_sigprint_this(this); arma_extra_debug_sigprint_this(this);
} }
template<typename eT>
running_stat_vec<eT>::running_stat_vec(const running_stat_vec<eT>& in_rsv)
: calc_cov (in_rsv.calc_cov)
, counter (in_rsv.counter)
, r_mean (in_rsv.r_mean)
, r_var (in_rsv.r_var)
, r_cov (in_rsv.r_cov)
, min_val (in_rsv.min_val)
, max_val (in_rsv.max_val)
, min_val_norm(in_rsv.min_val_norm)
, max_val_norm(in_rsv.max_val_norm)
{
arma_extra_debug_sigprint_this(this);
}
template<typename eT>
const running_stat_vec<eT>&
running_stat_vec<eT>::operator=(const running_stat_vec<eT>& in_rsv)
{
arma_extra_debug_sigprint();
access::rw(calc_cov) = in_rsv.calc_cov;
counter = in_rsv.counter;
r_mean = in_rsv.r_mean;
r_var = in_rsv.r_var;
r_cov = in_rsv.r_cov;
min_val = in_rsv.min_val;
max_val = in_rsv.max_val;
min_val_norm = in_rsv.min_val_norm;
max_val_norm = in_rsv.max_val_norm;
return *this;
}
//! update statistics to reflect new sample //! update statistics to reflect new sample
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
running_stat_vec<eT>::operator() (const Base<typename get_pod_type<eT>::res ult, T1>& X) running_stat_vec<eT>::operator() (const Base<typename get_pod_type<eT>::res ult, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//typedef typename get_pod_type<eT>::result T; //typedef typename get_pod_type<eT>::result T;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& sample = tmp.M; const Mat<eT>& sample = tmp.M;
arma_check( (sample.is_finite() == false), "running_stat_vec: given sampl e has non-finite elements" ); arma_check( (sample.is_finite() == false), "running_stat_vec: given sampl e has non-finite elements" );
running_stat_vec_aux::update_stats(*this, sample); running_stat_vec_aux::update_stats(*this, sample);
} }
//! update statistics to reflect new sample (version for complex numbers) //! update statistics to reflect new sample (version for complex numbers)
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
arma_hot
inline inline
void void
running_stat_vec<eT>::operator() (const Base<std::complex<typename get_pod_ type<eT>::result>, T1>& X) running_stat_vec<eT>::operator() (const Base<std::complex<typename get_pod_ type<eT>::result>, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
//typedef typename std::complex<typename get_pod_type<eT>::result> eT; //typedef typename std::complex<typename get_pod_type<eT>::result> eT;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& sample = tmp.M; const Mat<eT>& sample = tmp.M;
skipping to change at line 89 skipping to change at line 126
r_mean.reset(); r_mean.reset();
r_var.reset(); r_var.reset();
r_cov.reset(); r_cov.reset();
min_val.reset(); min_val.reset();
max_val.reset(); max_val.reset();
min_val_norm.reset(); min_val_norm.reset();
max_val_norm.reset(); max_val_norm.reset();
r_var_dummy.reset();
r_cov_dummy.reset();
tmp1.reset();
tmp2.reset();
} }
//! mean or average value //! mean or average value
template<typename eT> template<typename eT>
inline inline
Mat<eT> const Mat<eT>&
running_stat_vec<eT>::mean() running_stat_vec<eT>::mean() const
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return r_mean; return r_mean;
} }
//! variance //! variance
template<typename eT> template<typename eT>
inline inline
Mat<typename get_pod_type<eT>::result>; const Mat<typename get_pod_type<eT>::result>&;
running_stat_vec<eT>::var(const u32 norm_type) running_stat_vec<eT>::var(const u32 norm_type)
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return r_var; return r_var;
} }
else else
{ {
const T N_minus_1 = counter.value_minus_1(); const T N_minus_1 = counter.value_minus_1();
return (N_minus_1/N) * r_var;
r_var_dummy = (N_minus_1/N) * r_var;
return r_var_dummy;
} }
} }
else else
{ {
return zeros< Mat<typename get_pod_type<eT>::result> >(r_mean.n_rows, r r_var_dummy.zeros(r_mean.n_rows, r_mean.n_cols);
_mean.n_cols);
return r_var_dummy;
} }
} }
//! standard deviation //! standard deviation
template<typename eT> template<typename eT>
inline inline
Mat<typename get_pod_type<eT>::result> Mat<typename get_pod_type<eT>::result>
running_stat_vec<eT>::stddev(const u32 norm_type) running_stat_vec<eT>::stddev(const u32 norm_type) const
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return sqrt( (*this).var(norm_type) ); const T N = counter.value();
if(N > T(1))
{
if(norm_type == 0)
{
return sqrt(r_var);
}
else
{
const T N_minus_1 = counter.value_minus_1();
return sqrt( (N_minus_1/N) * r_var );
}
}
else
{
return Mat<T>();
}
} }
//! covariance //! covariance
template<typename eT> template<typename eT>
inline inline
Mat<eT>; const Mat<eT>&;
running_stat_vec<eT>::cov(const u32 norm_type) running_stat_vec<eT>::cov(const u32 norm_type)
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(calc_cov == true) if(calc_cov == true)
{ {
const T N = counter.value(); const T N = counter.value();
if(N > T(1)) if(N > T(1))
{ {
if(norm_type == 0) if(norm_type == 0)
{ {
return r_cov; return r_cov;
} }
else else
{ {
const T N_minus_1 = counter.value_minus_1(); const T N_minus_1 = counter.value_minus_1();
return (N_minus_1/N) * r_cov;
r_cov_dummy = (N_minus_1/N) * r_cov;
return r_cov_dummy;
} }
} }
else else
{ {
return zeros< Mat<eT> >(r_mean.n_rows, r_mean.n_cols); r_cov_dummy.zeros(r_mean.n_rows, r_mean.n_cols);
return r_cov_dummy;
} }
} }
else else
{ {
return Mat<eT>(); r_cov_dummy.reset();
return r_cov_dummy;
} }
} }
//! vector with minimum values //! vector with minimum values
template<typename eT> template<typename eT>
inline inline
Mat<eT> const Mat<eT>&
running_stat_vec<eT>::min() running_stat_vec<eT>::min() const
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return min_val; return min_val;
} }
//! vector with maximum values //! vector with maximum values
template<typename eT> template<typename eT>
inline inline
Mat<eT> const Mat<eT>&
running_stat_vec<eT>::max() running_stat_vec<eT>::max() const
const
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return max_val; return max_val;
} }
// //
//! update statistics to reflect new sample //! update statistics to reflect new sample
template<typename eT> template<typename eT>
skipping to change at line 236 skipping to change at line 303
eT* r_mean_mem = x.r_mean.memptr(); eT* r_mean_mem = x.r_mean.memptr();
T* r_var_mem = x.r_var.memptr(); T* r_var_mem = x.r_var.memptr();
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
const T N_plus_1 = x.counter.value_plus_1(); const T N_plus_1 = x.counter.value_plus_1();
const T N_minus_1 = x.counter.value_minus_1(); const T N_minus_1 = x.counter.value_minus_1();
if(x.calc_cov == true) if(x.calc_cov == true)
{ {
const Mat<eT> tmp1 = sample - x.r_mean; Mat<eT>& tmp1 = x.tmp1;
Mat<eT>& tmp2 = x.tmp2;
Mat<eT> tmp2; tmp1 = sample - x.r_mean;
if(sample.n_cols == 1) if(sample.n_cols == 1)
{ {
tmp2 = tmp1*trans(tmp1); tmp2 = tmp1*trans(tmp1);
} }
else else
{ {
tmp2 = trans(tmp1)*tmp1; tmp2 = trans(tmp1)*tmp1;
} }
skipping to change at line 353 skipping to change at line 421
eT* min_val_mem = x.min_val.memptr(); eT* min_val_mem = x.min_val.memptr();
eT* max_val_mem = x.max_val.memptr(); eT* max_val_mem = x.max_val.memptr();
T* min_val_norm_mem = x.min_val_norm.memptr(); T* min_val_norm_mem = x.min_val_norm.memptr();
T* max_val_norm_mem = x.max_val_norm.memptr(); T* max_val_norm_mem = x.max_val_norm.memptr();
const T N_plus_1 = x.counter.value_plus_1(); const T N_plus_1 = x.counter.value_plus_1();
const T N_minus_1 = x.counter.value_minus_1(); const T N_minus_1 = x.counter.value_minus_1();
if(x.calc_cov == true) if(x.calc_cov == true)
{ {
const Mat<eT> tmp1 = sample - x.r_mean; Mat<eT>& tmp1 = x.tmp1;
Mat<eT>& tmp2 = x.tmp2;
Mat<eT> tmp2; tmp1 = sample - x.r_mean;
if(sample.n_cols == 1) if(sample.n_cols == 1)
{ {
tmp2 = conj(tmp1)*trans(tmp1); tmp2 = conj(tmp1)*trans(tmp1);
} }
else else
{ {
tmp2 = trans(conj(tmp1))*tmp1; tmp2 = trans(conj(tmp1))*tmp1;
} }
 End of changes. 22 change blocks. 
26 lines changed or deleted 94 lines changed or added


 running_stat_vec_proto.hpp   running_stat_vec_proto.hpp 
skipping to change at line 33 skipping to change at line 33
template<typename eT> template<typename eT>
class running_stat_vec class running_stat_vec
{ {
public: public:
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
inline ~running_stat_vec(); inline ~running_stat_vec();
inline running_stat_vec(const bool in_calc_cov = false); inline running_stat_vec(const bool in_calc_cov = false);
template<typename T1> inline void operator() (const Base< T inline running_stat_vec(const running_stat_vec& in_rsv);
, T1>& X);
template<typename T1> inline void operator() (const Base< std::complex<T> inline const running_stat_vec& operator=(const running_stat_vec& in_rsv);
, T1>& X);
template<typename T1> arma_hot inline void operator() (const Base<
T, T1>& X);
template<typename T1> arma_hot inline void operator() (const Base< std::c
omplex<T>, T1>& X);
inline void reset(); inline void reset();
inline Mat<eT>; mean() const; inline const Mat<eT>&; mean() const;
inline Mat< T> var (const u32 norm_type = 0) const; inline const Mat< T>& var (const u32 norm_type = 0);
inline Mat< T> stddev(const u32 norm_type = 0) const; inline Mat< T> stddev(const u32 norm_type = 0) const;
inline Mat<eT> cov (const u32 norm_type = 0) const; inline const Mat<eT>& cov (const u32 norm_type = 0);
inline Mat<eT> min() const; inline const Mat<eT>& min() const;
inline Mat<eT> max() const; inline const Mat<eT>& max() const;
// //
// //
private: private:
const bool calc_cov; const bool calc_cov;
arma_aligned arma_counter<T> counter; arma_aligned arma_counter<T> counter;
arma_aligned Mat<eT> r_mean; arma_aligned Mat<eT> r_mean;
arma_aligned Mat< T> r_var; arma_aligned Mat< T> r_var;
arma_aligned Mat<eT> r_cov; arma_aligned Mat<eT> r_cov;
arma_aligned Mat<eT> min_val; arma_aligned Mat<eT> min_val;
arma_aligned Mat<eT> max_val; arma_aligned Mat<eT> max_val;
arma_aligned Mat< T> min_val_norm; arma_aligned Mat< T> min_val_norm;
arma_aligned Mat< T> max_val_norm; arma_aligned Mat< T> max_val_norm;
arma_aligned Mat< T> r_var_dummy;
arma_aligned Mat<eT> r_cov_dummy;
arma_aligned Mat<eT> tmp1;
arma_aligned Mat<eT> tmp2;
friend class running_stat_vec_aux; friend class running_stat_vec_aux;
}; };
class running_stat_vec_aux class running_stat_vec_aux
{ {
public: public:
template<typename eT> template<typename eT>
inline static void update_stats(running_stat_vec< eT >& x, c onst Mat<eT>& sample); inline static void update_stats(running_stat_vec< eT >& x, c onst Mat<eT>& sample);
 End of changes. 5 change blocks. 
10 lines changed or deleted 20 lines changed or added


 subview_meat.hpp   subview_meat.hpp 
skipping to change at line 161 skipping to change at line 161
} }
} }
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator= (const Base<eT,T1>& in) subview<eT>::operator_equ_mat(const Base<eT,T1>& in)
{
arma_extra_debug_sigprint();
const unwrap<T1> tmp(in.get_ref());
const Mat<eT>& x = tmp.M;
subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix");
const u32 t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows;
for(u32 col=0; col<t_n_cols; ++col)
{
syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
}
}
template<typename eT>
template<typename T1>
inline
void
subview<eT>::operator_equ_proxy(const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const Proxy<T1> x(in.get_ref()); const Proxy<T1> x(in.get_ref());
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix"); arma_debug_assert_same_size(t, x, "insert into submatrix");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_cols = t.n_cols;
const u32 t_n_rows = t.n_rows;
for(u32 col = 0; col<t_n_cols; ++col)
{ {
eT* t_coldata = t.colptr(col); eT* t_coldata = t.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row) for(u32 row = 0; row<t_n_rows; ++row)
{ {
t_coldata[row] = x.at(row,col); t_coldata[row] = x.at(row,col);
} }
} }
}
template<typename eT>
template<typename T1>
arma_inline
void
subview<eT>::operator= (const Base<eT,T1>& in)
{
arma_extra_debug_sigprint();
(is_Mat<T1>::value == true) ? operator_equ_mat(in) : operator_equ_proxy(i
n);
} }
template<typename eT> template<typename eT>
template<typename T1> template<typename T1>
inline inline
void void
subview<eT>::operator+= (const Base<eT,T1>& in) subview<eT>::operator+= (const Base<eT,T1>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 305 skipping to change at line 343
const bool overlap = check_overlap(x_in); const bool overlap = check_overlap(x_in);
Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0; Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0; const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in .aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
const subview<eT>& x = overlap ? (*tmp_subview) : x_in; const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
subview<eT>& t = *this; subview<eT>& t = *this;
arma_debug_assert_same_size(t, x, "insert into submatrix"); arma_debug_assert_same_size(t, x, "insert into submatrix");
for(u32 col = 0; col<t.n_cols; ++col) const u32 t_n_cols = t.n_cols;
{ const u32 t_n_rows = t.n_rows;
eT* t_coldata = t.colptr(col);
const eT* x_coldata = x.colptr(col);
for(u32 row = 0; row<t.n_rows; ++row)
{
t_coldata[row] = x_coldata[row];
}
for(u32 col = 0; col<t_n_cols; ++col)
{
syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
} }
if(overlap) if(overlap)
{ {
delete tmp_subview; delete tmp_subview;
delete tmp_mat; delete tmp_mat;
} }
} }
skipping to change at line 700 skipping to change at line 734
out_mem[i] = X.at(row, i+start_col); out_mem[i] = X.at(row, i+start_col);
} }
} }
} }
else // general submatrix else // general submatrix
{ {
arma_extra_debug_print("subview::extract(): general submatrix"); arma_extra_debug_print("subview::extract(): general submatrix");
for(u32 col = 0; col<n_cols; ++col) for(u32 col = 0; col<n_cols; ++col)
{ {
eT* out_coldata = out.colptr(col); syslib::copy_elem( out.colptr(col), in.colptr(col), n_rows );
const eT* in_coldata = in.colptr(col);
for(u32 row = 0; row<n_rows; ++row)
{
out_coldata[row] = in_coldata[row];
}
} }
} }
if(alias) if(alias)
{ {
actual_out = out; actual_out = out;
delete tmp; delete tmp;
} }
} }
 End of changes. 8 change blocks. 
20 lines changed or deleted 49 lines changed or added


 subview_proto.hpp   subview_proto.hpp 
skipping to change at line 56 skipping to change at line 56
public: public:
inline ~subview(); inline ~subview();
inline void operator+= (const eT val); inline void operator+= (const eT val);
inline void operator-= (const eT val); inline void operator-= (const eT val);
inline void operator*= (const eT val); inline void operator*= (const eT val);
inline void operator/= (const eT val); inline void operator/= (const eT val);
template<typename T1> inline void operator_equ_mat (const Base<eT,T1>& x
);
template<typename T1> inline void operator_equ_proxy(const Base<eT,T1>& x
);
// deliberately returning void // deliberately returning void
template<typename T1> inline void operator= (const Base<eT,T1>& x); template<typename T1> inline void operator= (const Base<eT,T1>& x);
template<typename T1> inline void operator+= (const Base<eT,T1>& x); template<typename T1> inline void operator+= (const Base<eT,T1>& x);
template<typename T1> inline void operator-= (const Base<eT,T1>& x); template<typename T1> inline void operator-= (const Base<eT,T1>& x);
template<typename T1> inline void operator%= (const Base<eT,T1>& x); template<typename T1> inline void operator%= (const Base<eT,T1>& x);
template<typename T1> inline void operator/= (const Base<eT,T1>& x); template<typename T1> inline void operator/= (const Base<eT,T1>& x);
inline void operator= (const subview& x); inline void operator= (const subview& x);
inline void operator+= (const subview& x); inline void operator+= (const subview& x);
inline void operator-= (const subview& x); inline void operator-= (const subview& x);
 End of changes. 1 change blocks. 
0 lines changed or deleted 5 lines changed or added


 syslib_proto.hpp   syslib_proto.hpp 
skipping to change at line 30 skipping to change at line 30
{ {
public: public:
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
static static
void void
copy_elem(eT* dest, const eT* src, const u32 n_elem) copy_elem(eT* dest, const eT* src, const u32 n_elem)
{ {
if( n_elem <= (128/sizeof(eT)) ) #if !defined(__OPTIMIZE__)
{ {
u32 i,j; std::memcpy(dest, src, n_elem*sizeof(eT));
}
for(i=0, j=1; j<n_elem; i+=2, j+=2) #else
{
switch(n_elem)
{ {
dest[i] = src[i]; case 0:
dest[j] = src[j]; break;
}
if(i < n_elem) case 1:
{ *dest = *src;
dest[i] = src[i]; break;
case 2:
dest[0] = src[0];
dest[1] = src[1];
break;
case 3:
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
break;
case 4:
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = src[3];
break;
default:
if( n_elem <= (128/sizeof(eT)) )
{
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
dest[i] = src[i];
dest[j] = src[j];
}
if(i < n_elem)
{
dest[i] = src[i];
}
}
else
{
std::memcpy(dest, src, n_elem*sizeof(eT));
}
} }
} }
else #endif
}
template<typename out_eT, typename in_eT>
arma_hot
inline
static
void
copy_and_convert_elem(out_eT* dest, const in_eT* src, const u32 n_elem)
{
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
std::memcpy(dest, src, n_elem*sizeof(eT)); dest[i] = out_eT( src[i] );
dest[j] = out_eT( src[j] );
}
if(i < n_elem)
{
dest[i] = out_eT( src[i] );
}
}
//
// TODO: the functions below will need more work
template<typename out_eT, typename in_eT>
arma_hot
arma_inline
static
void
convert_cx_scalar(out_eT& out, const in_eT& in)
{
out = out_eT(in);
}
template<typename out_eT, typename in_T>
arma_hot
arma_inline
static
void
convert_cx_scalar(out_eT& out, const std::complex<in_T>& in)
{
out = out_eT( in.real() );
}
template<typename out_T, typename in_T>
arma_hot
arma_inline
static
void
convert_cx_scalar(std::complex<out_T>& out, const std::complex<in_T>& in)
{
typedef std::complex<out_T> out_eT;
out = out_eT(in);
}
template<typename out_eT, typename in_eT>
arma_hot
inline
static
void
copy_and_convert_cx_elem(out_eT* dest, const in_eT* src, const u32 n_elem
)
{
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
convert_cx_scalar( dest[i], src[i] );
convert_cx_scalar( dest[j], src[j] );
} }
if(i < n_elem)
{
convert_cx_scalar( dest[i], src[i] );
}
} }
}; };
//! @} //! @}
 End of changes. 7 change blocks. 
12 lines changed or deleted 126 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/