keyword stringclasses 7 values | repo_name stringlengths 8 98 | file_path stringlengths 4 244 | file_extension stringclasses 29 values | file_size int64 0 84.1M | line_count int64 0 1.6M | content stringlengths 1 84.1M ⌀ | language stringclasses 14 values |
|---|---|---|---|---|---|---|---|
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_partial_lu.hh | .hh | 3,188 | 126 | //=====================================================
// File : action_lu_decomp.hh
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_PARTIAL_LU
#define ACTION_PARTIAL_LU
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_partial_lu {
public :
// Ctor
Action_partial_lu( int size ):_size(size)
{
MESSAGE("Action_partial_lu Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
init_matrix<null_function>(C_stl,_size);
// make sure X is invertible
for (int i=0; i<_size; ++i)
X_stl[i][i] = X_stl[i][i] * 1e2 + 1;
// generic matrix and vector initialization
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(C,C_stl);
_cost = 2.0*size*size*size/3.0 + size*size;
}
// invalidate copy ctor
Action_partial_lu( const Action_partial_lu & )
{
INFOS("illegal call to Action_partial_lu Copy Ctor");
exit(1);
}
// Dtor
~Action_partial_lu( void ){
MESSAGE("Action_partial_lu Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
}
// action name
static inline std::string name( void )
{
return "partial_lu_decomp_"+Interface::name();
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::partial_lu_decomp(X,C,_size);
}
void check_result( void ){
// calculation check
// Interface::matrix_to_stl(C,resu_stl);
// STL_interface<typename Interface::real_type>::lu_decomp(X_stl,C_stl,_size);
//
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
//
// if (error>1.e-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// }
}
private :
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix X;
typename Interface::gene_matrix C;
int _size;
double _cost;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_trmm.hh | .hh | 3,907 | 166 | //=====================================================
// File : action_matrix_matrix_product.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_TRMM
#define ACTION_TRMM
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_trmm {
public :
// Ctor
Action_trmm( int size ):_size(size)
{
MESSAGE("Action_trmm Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<pseudo_random>(B_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
for (int j=0; j<_size; ++j)
{
for (int i=0; i<j; ++i)
A_stl[j][i] = 0;
A_stl[j][j] += 3;
}
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
_cost += 2*j + 1;
}
_cost *= _size;
}
// invalidate copy ctor
Action_trmm( const Action_trmm & )
{
INFOS("illegal call to Action_trmm Copy Ctor");
exit(0);
}
// Dtor
~Action_trmm( void ){
MESSAGE("Action_trmm Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(B,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(B_ref,_size);
Interface::free_matrix(X_ref,_size);
}
// action name
static inline std::string name( void )
{
return "trmm_"+Interface::name();
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(B_ref,B,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::trmm(A,B,X,_size);
}
void check_result( void ){
// calculation check
// Interface::matrix_to_stl(X,resu_stl);
//
// STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,_size);
//
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
//
// if (error>1.e-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// // exit(1);
// }
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_matrix B_ref;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_matrix B;
typename Interface::gene_matrix X;
int _size;
double _cost;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/basic_actions.hh | .hh | 467 | 22 |
#include "action_axpy.hh"
#include "action_axpby.hh"
#include "action_matrix_vector_product.hh"
#include "action_atv_product.hh"
#include "action_matrix_matrix_product.hh"
// #include "action_ata_product.hh"
#include "action_aat_product.hh"
#include "action_trisolve.hh"
#include "action_trmm.hh"
#include "action_symv.hh"
// #include "action_symm.hh"
#include "action_syr2.hh"
#include "action_ger.hh"
#include "action_rot.hh"
// #include "action_lu_solve.hh"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_matrix_matrix_product.hh | .hh | 3,886 | 151 | //=====================================================
// File : action_matrix_matrix_product.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_MATRIX_MATRIX_PRODUCT
#define ACTION_MATRIX_MATRIX_PRODUCT
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_matrix_matrix_product {
public :
// Ctor
Action_matrix_matrix_product( int size ):_size(size)
{
MESSAGE("Action_matrix_matrix_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<pseudo_random>(B_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_matrix_matrix_product( const Action_matrix_matrix_product & )
{
INFOS("illegal call to Action_matrix_matrix_product Copy Ctor");
exit(0);
}
// Dtor
~Action_matrix_matrix_product( void ){
MESSAGE("Action_matrix_matrix_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(B,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(B_ref,_size);
Interface::free_matrix(X_ref,_size);
}
// action name
static inline std::string name( void )
{
return "matrix_matrix_"+Interface::name();
}
double nb_op_base( void ){
return 2.0*_size*_size*_size;
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(B_ref,B,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::matrix_matrix_product(A,B,X,_size);
}
void check_result( void ){
// calculation check
if (_size<200)
{
Interface::matrix_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_matrix B_ref;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_matrix B;
typename Interface::gene_matrix X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_hessenberg.hh | .hh | 5,598 | 234 | //=====================================================
// File : action_hessenberg.hh
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_HESSENBERG
#define ACTION_HESSENBERG
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_hessenberg {
public :
// Ctor
Action_hessenberg( int size ):_size(size)
{
MESSAGE("Action_hessenberg Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
init_matrix<null_function>(C_stl,_size);
init_matrix<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(C,C_stl);
_cost = 0;
for (int j=0; j<_size-2; ++j)
{
double r = std::max(0,_size-j-1);
double b = std::max(0,_size-j-2);
_cost += 6 + 3*b + r*r*4 + r*_size*4;
}
}
// invalidate copy ctor
Action_hessenberg( const Action_hessenberg & )
{
INFOS("illegal call to Action_hessenberg Copy Ctor");
exit(1);
}
// Dtor
~Action_hessenberg( void ){
MESSAGE("Action_hessenberg Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
}
// action name
static inline std::string name( void )
{
return "hessenberg_"+Interface::name();
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::hessenberg(X,C,_size);
}
void check_result( void ){
// calculation check
Interface::matrix_to_stl(C,resu_stl);
// STL_interface<typename Interface::real_type>::hessenberg(X_stl,C_stl,_size);
//
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
//
// if (error>1.e-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// }
}
private :
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix X;
typename Interface::gene_matrix C;
int _size;
double _cost;
};
template<class Interface>
class Action_tridiagonalization {
public :
// Ctor
Action_tridiagonalization( int size ):_size(size)
{
MESSAGE("Action_tridiagonalization Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
for(int i=0; i<_size; ++i)
{
for(int j=0; j<i; ++j)
X_stl[i][j] = X_stl[j][i];
}
init_matrix<null_function>(C_stl,_size);
init_matrix<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(C,C_stl);
_cost = 0;
for (int j=0; j<_size-2; ++j)
{
double r = std::max(0,_size-j-1);
double b = std::max(0,_size-j-2);
_cost += 6. + 3.*b + r*r*8.;
}
}
// invalidate copy ctor
Action_tridiagonalization( const Action_tridiagonalization & )
{
INFOS("illegal call to Action_tridiagonalization Copy Ctor");
exit(1);
}
// Dtor
~Action_tridiagonalization( void ){
MESSAGE("Action_tridiagonalization Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
}
// action name
static inline std::string name( void ) { return "tridiagonalization_"+Interface::name(); }
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::tridiagonalization(X,C,_size);
}
void check_result( void ){
// calculation check
Interface::matrix_to_stl(C,resu_stl);
// STL_interface<typename Interface::real_type>::tridiagonalization(X_stl,C_stl,_size);
//
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
//
// if (error>1.e-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// }
}
private :
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix X;
typename Interface::gene_matrix C;
int _size;
double _cost;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_matrix_vector_product.hh | .hh | 3,989 | 154 | //=====================================================
// File : action_matrix_vector_product.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_MATRIX_VECTOR_PRODUCT
#define ACTION_MATRIX_VECTOR_PRODUCT
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_matrix_vector_product {
public :
// Ctor
BTL_DONT_INLINE Action_matrix_vector_product( int size ):_size(size)
{
MESSAGE("Action_matrix_vector_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<null_function>(X_stl,_size);
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_matrix_vector_product( const Action_matrix_vector_product & )
{
INFOS("illegal call to Action_matrix_vector_product Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_matrix_vector_product( void ){
MESSAGE("Action_matrix_vector_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
Interface::free_vector(B_ref);
Interface::free_vector(X_ref);
}
// action name
static inline std::string name( void )
{
return "matrix_vector_" + Interface::name();
}
double nb_op_base( void ){
return 2.0*_size*_size;
}
BTL_DONT_INLINE void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_vector(B_ref,B,_size);
Interface::copy_vector(X_ref,X,_size);
}
BTL_DONT_INLINE void calculate( void ) {
BTL_ASM_COMMENT("#begin matrix_vector_product");
Interface::matrix_vector_product(A,B,X,_size);
BTL_ASM_COMMENT("end matrix_vector_product");
}
BTL_DONT_INLINE void check_result( void ){
// calculation check
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl,B_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-5){
INFOS("WRONG CALCULATION...residual=" << error);
exit(0);
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_vector B_ref;
typename Interface::gene_vector X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_axpy.hh | .hh | 3,340 | 140 | //=====================================================
// File : action_axpy.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_AXPY
#define ACTION_AXPY
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_axpy {
public :
// Ctor
Action_axpy( int size ):_coef(1.0),_size(size)
{
MESSAGE("Action_axpy Ctor");
// STL vector initialization
init_vector<pseudo_random>(X_stl,_size);
init_vector<pseudo_random>(Y_stl,_size);
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(Y_ref,Y_stl);
Interface::vector_from_stl(X,X_stl);
Interface::vector_from_stl(Y,Y_stl);
}
// invalidate copy ctor
Action_axpy( const Action_axpy & )
{
INFOS("illegal call to Action_axpy Copy Ctor");
exit(1);
}
// Dtor
~Action_axpy( void ){
MESSAGE("Action_axpy Dtor");
// deallocation
Interface::free_vector(X_ref);
Interface::free_vector(Y_ref);
Interface::free_vector(X);
Interface::free_vector(Y);
}
// action name
static inline std::string name( void )
{
return "axpy_"+Interface::name();
}
double nb_op_base( void ){
return 2.0*_size;
}
inline void initialize( void ){
Interface::copy_vector(X_ref,X,_size);
Interface::copy_vector(Y_ref,Y,_size);
}
inline void calculate( void ) {
BTL_ASM_COMMENT("mybegin axpy");
Interface::axpy(_coef,X,Y,_size);
BTL_ASM_COMMENT("myend axpy");
}
void check_result( void ){
if (_size>128) return;
// calculation check
Interface::vector_to_stl(Y,resu_stl);
STL_interface<typename Interface::real_type>::axpy(_coef,X_stl,Y_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(Y_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(0);
}
}
private :
typename Interface::stl_vector X_stl;
typename Interface::stl_vector Y_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_vector X_ref;
typename Interface::gene_vector Y_ref;
typename Interface::gene_vector X;
typename Interface::gene_vector Y;
typename Interface::real_type _coef;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_axpby.hh | .hh | 3,371 | 128 | //=====================================================
// File : action_axpby.hh
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_AXPBY
#define ACTION_AXPBY
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_axpby {
public :
// Ctor
Action_axpby( int size ):_alpha(0.5),_beta(0.95),_size(size)
{
MESSAGE("Action_axpby Ctor");
// STL vector initialization
init_vector<pseudo_random>(X_stl,_size);
init_vector<pseudo_random>(Y_stl,_size);
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(Y_ref,Y_stl);
Interface::vector_from_stl(X,X_stl);
Interface::vector_from_stl(Y,Y_stl);
}
// invalidate copy ctor
Action_axpby( const Action_axpby & )
{
INFOS("illegal call to Action_axpby Copy Ctor");
exit(1);
}
// Dtor
~Action_axpby( void ){
MESSAGE("Action_axpby Dtor");
// deallocation
Interface::free_vector(X_ref);
Interface::free_vector(Y_ref);
Interface::free_vector(X);
Interface::free_vector(Y);
}
// action name
static inline std::string name( void )
{
return "axpby_"+Interface::name();
}
double nb_op_base( void ){
return 3.0*_size;
}
inline void initialize( void ){
Interface::copy_vector(X_ref,X,_size);
Interface::copy_vector(Y_ref,Y,_size);
}
inline void calculate( void ) {
BTL_ASM_COMMENT("mybegin axpby");
Interface::axpby(_alpha,X,_beta,Y,_size);
BTL_ASM_COMMENT("myend axpby");
}
void check_result( void ){
if (_size>128) return;
// calculation check
Interface::vector_to_stl(Y,resu_stl);
STL_interface<typename Interface::real_type>::axpby(_alpha,X_stl,_beta,Y_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(Y_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(2);
}
}
private :
typename Interface::stl_vector X_stl;
typename Interface::stl_vector Y_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_vector X_ref;
typename Interface::gene_vector Y_ref;
typename Interface::gene_vector X;
typename Interface::gene_vector Y;
typename Interface::real_type _alpha;
typename Interface::real_type _beta;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_atv_product.hh | .hh | 3,670 | 135 | //=====================================================
// File : action_atv_product.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_ATV_PRODUCT
#define ACTION_ATV_PRODUCT
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_atv_product {
public :
Action_atv_product( int size ) : _size(size)
{
MESSAGE("Action_atv_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<null_function>(X_stl,_size);
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_atv_product( const Action_atv_product & )
{
INFOS("illegal call to Action_atv_product Copy Ctor");
exit(1);
}
~Action_atv_product( void )
{
MESSAGE("Action_atv_product Dtor");
Interface::free_matrix(A,_size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
Interface::free_vector(B_ref);
Interface::free_vector(X_ref);
}
static inline std::string name() { return "atv_" + Interface::name(); }
double nb_op_base( void ) { return 2.0*_size*_size; }
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_vector(B_ref,B,_size);
Interface::copy_vector(X_ref,X,_size);
}
BTL_DONT_INLINE void calculate( void ) {
BTL_ASM_COMMENT("begin atv");
Interface::atv_product(A,B,X,_size);
BTL_ASM_COMMENT("end atv");
}
void check_result( void )
{
if (_size>128) return;
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::atv_product(A_stl,B_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_vector B_ref;
typename Interface::gene_vector X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_syr2.hh | .hh | 3,664 | 134 | //=====================================================
// File : action_syr2.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_SYR2
#define ACTION_SYR2
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_syr2 {
public :
// Ctor
BTL_DONT_INLINE Action_syr2( int size ):_size(size)
{
// STL matrix and vector initialization
typename Interface::stl_matrix tmp;
init_matrix<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<pseudo_random>(X_stl,_size);
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_syr2( const Action_syr2 & )
{
INFOS("illegal call to Action_syr2 Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_syr2( void ){
Interface::free_matrix(A,_size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
Interface::free_vector(B_ref);
Interface::free_vector(X_ref);
}
// action name
static inline std::string name( void )
{
return "syr2_" + Interface::name();
}
double nb_op_base( void ){
return 2.0*_size*_size;
}
BTL_DONT_INLINE void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_vector(B_ref,B,_size);
Interface::copy_vector(X_ref,X,_size);
}
BTL_DONT_INLINE void calculate( void ) {
BTL_ASM_COMMENT("#begin syr2");
Interface::syr2(A,B,X,_size);
BTL_ASM_COMMENT("end syr2");
}
BTL_DONT_INLINE void check_result( void ){
// calculation check
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::syr2(A_stl,B_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-3){
INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_vector B_ref;
typename Interface::gene_vector X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_cholesky.hh | .hh | 3,202 | 129 | //=====================================================
// File : action_cholesky.hh
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_CHOLESKY
#define ACTION_CHOLESKY
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_cholesky {
public :
// Ctor
Action_cholesky( int size ):_size(size)
{
MESSAGE("Action_cholesky Ctor");
// STL mat/vec initialization
init_matrix_symm<pseudo_random>(X_stl,_size);
init_matrix<null_function>(C_stl,_size);
// make sure X is invertible
for (int i=0; i<_size; ++i)
X_stl[i][i] = std::abs(X_stl[i][i]) * 1e2 + 100;
// generic matrix and vector initialization
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(C,C_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
double r = std::max(_size - j -1,0);
_cost += 2*(r*j+r+j);
}
}
// invalidate copy ctor
Action_cholesky( const Action_cholesky & )
{
INFOS("illegal call to Action_cholesky Copy Ctor");
exit(1);
}
// Dtor
~Action_cholesky( void ){
MESSAGE("Action_cholesky Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
}
// action name
static inline std::string name( void )
{
return "cholesky_"+Interface::name();
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::cholesky(X,C,_size);
}
void check_result( void ){
// calculation check
// STL_interface<typename Interface::real_type>::cholesky(X_stl,C_stl,_size);
//
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
//
// if (error>1.e-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// }
}
private :
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix X;
typename Interface::gene_matrix C;
int _size;
double _cost;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_matrix_matrix_product_bis.hh | .hh | 3,982 | 153 | //=====================================================
// File : action_matrix_matrix_product_bis.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_MATRIX_MATRIX_PRODUCT_BIS
#define ACTION_MATRIX_MATRIX_PRODUCT_BIS
#include "utilities.h"
#include "STL_interface.hh"
#include "STL_timer.hh"
#include <string>
#include "init_function.hh"
#include "init_vector.hh"
#include "init_matrix.hh"
using namespace std;
template<class Interface>
class Action_matrix_matrix_product_bis {
public :
static inline std::string name( void )
{
return "matrix_matrix_"+Interface::name();
}
static double nb_op_base(int size){
return 2.0*size*size*size;
}
static double calculate( int nb_calc, int size ) {
// STL matrix and vector initialization
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix B_stl;
typename Interface::stl_matrix X_stl;
init_matrix<pseudo_random>(A_stl,size);
init_matrix<pseudo_random>(B_stl,size);
init_matrix<null_function>(X_stl,size);
// generic matrix and vector initialization
typename Interface::gene_matrix A_ref;
typename Interface::gene_matrix B_ref;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_matrix B;
typename Interface::gene_matrix X;
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(B_ref,B_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(B,B_stl);
Interface::matrix_from_stl(X,X_stl);
// STL_timer utilities
STL_timer chronos;
// Baseline evaluation
chronos.start_baseline(nb_calc);
do {
Interface::copy_matrix(A_ref,A,size);
Interface::copy_matrix(B_ref,B,size);
Interface::copy_matrix(X_ref,X,size);
// Interface::matrix_matrix_product(A,B,X,size); This line must be commented !!!!
}
while(chronos.check());
chronos.report(true);
// Time measurement
chronos.start(nb_calc);
do {
Interface::copy_matrix(A_ref,A,size);
Interface::copy_matrix(B_ref,B,size);
Interface::copy_matrix(X_ref,X,size);
Interface::matrix_matrix_product(A,B,X,size); // here it is not commented !!!!
}
while(chronos.check());
chronos.report(true);
double time=chronos.calculated_time/2000.0;
// calculation check
typename Interface::stl_matrix resu_stl(size);
Interface::matrix_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
// deallocation and return time
Interface::free_matrix(A,size);
Interface::free_matrix(B,size);
Interface::free_matrix(X,size);
Interface::free_matrix(A_ref,size);
Interface::free_matrix(B_ref,size);
Interface::free_matrix(X_ref,size);
return time;
}
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_trisolve.hh | .hh | 3,425 | 138 | //=====================================================
// File : action_trisolve.hh
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_TRISOLVE
#define ACTION_TRISOLVE
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_trisolve {
public :
// Ctor
Action_trisolve( int size ):_size(size)
{
MESSAGE("Action_trisolve Ctor");
// STL vector initialization
init_matrix<pseudo_random>(L_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<null_function>(X_stl,_size);
for (int j=0; j<_size; ++j)
{
for (int i=0; i<j; ++i)
L_stl[j][i] = 0;
L_stl[j][j] += 3;
}
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(L,L_stl);
Interface::vector_from_stl(X,X_stl);
Interface::vector_from_stl(B,B_stl);
_cost = 0;
for (int j=0; j<_size; ++j)
{
_cost += 2*j + 1;
}
}
// invalidate copy ctor
Action_trisolve( const Action_trisolve & )
{
INFOS("illegal call to Action_trisolve Copy Ctor");
exit(1);
}
// Dtor
~Action_trisolve( void ){
MESSAGE("Action_trisolve Dtor");
// deallocation
Interface::free_matrix(L,_size);
Interface::free_vector(B);
Interface::free_vector(X);
}
// action name
static inline std::string name( void )
{
return "trisolve_vector_"+Interface::name();
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
//Interface::copy_vector(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::trisolve_lower(L,B,X,_size);
}
void check_result(){
if (_size>128) return;
// calculation check
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::trisolve_lower(L_stl,B_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-4){
INFOS("WRONG CALCULATION...residual=" << error);
exit(2);
} //else INFOS("CALCULATION OK...residual=" << error);
}
private :
typename Interface::stl_matrix L_stl;
typename Interface::stl_vector X_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_matrix L;
typename Interface::gene_vector X;
typename Interface::gene_vector B;
int _size;
double _cost;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_aat_product.hh | .hh | 3,374 | 146 | //=====================================================
// File : action_aat_product.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_AAT_PRODUCT
#define ACTION_AAT_PRODUCT
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_aat_product {
public :
// Ctor
Action_aat_product( int size ):_size(size)
{
MESSAGE("Action_aat_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_aat_product( const Action_aat_product & )
{
INFOS("illegal call to Action_aat_product Copy Ctor");
exit(0);
}
// Dtor
~Action_aat_product( void ){
MESSAGE("Action_aat_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(X_ref,_size);
}
// action name
static inline std::string name( void )
{
return "aat_"+Interface::name();
}
double nb_op_base( void ){
return double(_size)*double(_size)*double(_size);
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::aat_product(A,X,_size);
}
void check_result( void ){
if (_size>128) return;
// calculation check
Interface::matrix_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::aat_product(A_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_matrix X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_lu_decomp.hh | .hh | 3,151 | 125 | //=====================================================
// File : action_lu_decomp.hh
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_LU_DECOMP
#define ACTION_LU_DECOMP
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_lu_decomp {
public :
// Ctor
Action_lu_decomp( int size ):_size(size)
{
MESSAGE("Action_lu_decomp Ctor");
// STL vector initialization
init_matrix<pseudo_random>(X_stl,_size);
init_matrix<null_function>(C_stl,_size);
init_matrix<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(X,X_stl);
Interface::matrix_from_stl(C,C_stl);
_cost = 2.0*size*size*size/3.0 + size*size;
}
// invalidate copy ctor
Action_lu_decomp( const Action_lu_decomp & )
{
INFOS("illegal call to Action_lu_decomp Copy Ctor");
exit(1);
}
// Dtor
~Action_lu_decomp( void ){
MESSAGE("Action_lu_decomp Dtor");
// deallocation
Interface::free_matrix(X_ref,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(C,_size);
}
// action name
static inline std::string name( void )
{
return "complete_lu_decomp_"+Interface::name();
}
double nb_op_base( void ){
return _cost;
}
inline void initialize( void ){
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::lu_decomp(X,C,_size);
}
void check_result( void ){
// calculation check
Interface::matrix_to_stl(C,resu_stl);
// STL_interface<typename Interface::real_type>::lu_decomp(X_stl,C_stl,_size);
//
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
//
// if (error>1.e-6){
// INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// }
}
private :
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix C_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix X;
typename Interface::gene_matrix C;
int _size;
double _cost;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_ata_product.hh | .hh | 3,354 | 146 | //=====================================================
// File : action_ata_product.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_ATA_PRODUCT
#define ACTION_ATA_PRODUCT
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_ata_product {
public :
// Ctor
Action_ata_product( int size ):_size(size)
{
MESSAGE("Action_ata_product Ctor");
// STL matrix and vector initialization
init_matrix<pseudo_random>(A_stl,_size);
init_matrix<null_function>(X_stl,_size);
init_matrix<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(X_ref,X_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::matrix_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_ata_product( const Action_ata_product & )
{
INFOS("illegal call to Action_ata_product Copy Ctor");
exit(0);
}
// Dtor
~Action_ata_product( void ){
MESSAGE("Action_ata_product Dtor");
// deallocation
Interface::free_matrix(A,_size);
Interface::free_matrix(X,_size);
Interface::free_matrix(A_ref,_size);
Interface::free_matrix(X_ref,_size);
}
// action name
static inline std::string name( void )
{
return "ata_"+Interface::name();
}
double nb_op_base( void ){
return 2.0*_size*_size*_size;
}
inline void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_matrix(X_ref,X,_size);
}
inline void calculate( void ) {
Interface::ata_product(A,X,_size);
}
void check_result( void ){
if (_size>128) return;
// calculation check
Interface::matrix_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::ata_product(A_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-6){
INFOS("WRONG CALCULATION...residual=" << error);
exit(1);
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_matrix X_stl;
typename Interface::stl_matrix resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_matrix X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_matrix X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_rot.hh | .hh | 3,019 | 117 |
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_ROT
#define ACTION_ROT
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_rot {
public :
// Ctor
BTL_DONT_INLINE Action_rot( int size ):_size(size)
{
MESSAGE("Action_rot Ctor");
// STL matrix and vector initialization
typename Interface::stl_matrix tmp;
init_vector<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
// generic matrix and vector initialization
Interface::vector_from_stl(A_ref,A_stl);
Interface::vector_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(B,B_stl);
}
// invalidate copy ctor
Action_rot( const Action_rot & )
{
INFOS("illegal call to Action_rot Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_rot( void ){
MESSAGE("Action_rot Dtor");
Interface::free_vector(A);
Interface::free_vector(B);
Interface::free_vector(A_ref);
Interface::free_vector(B_ref);
}
// action name
static inline std::string name( void )
{
return "rot_" + Interface::name();
}
double nb_op_base( void ){
return 6.0*_size;
}
BTL_DONT_INLINE void initialize( void ){
Interface::copy_vector(A_ref,A,_size);
Interface::copy_vector(B_ref,B,_size);
}
BTL_DONT_INLINE void calculate( void ) {
BTL_ASM_COMMENT("#begin rot");
Interface::rot(A,B,0.5,0.6,_size);
BTL_ASM_COMMENT("end rot");
}
BTL_DONT_INLINE void check_result( void ){
// calculation check
// Interface::vector_to_stl(X,resu_stl);
// STL_interface<typename Interface::real_type>::rot(A_stl,B_stl,X_stl,_size);
// typename Interface::real_type error=
// STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
// if (error>1.e-3){
// INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
// }
}
private :
typename Interface::stl_vector A_stl;
typename Interface::stl_vector B_stl;
typename Interface::gene_vector A_ref;
typename Interface::gene_vector B_ref;
typename Interface::gene_vector A;
typename Interface::gene_vector B;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_lu_solve.hh | .hh | 3,598 | 137 | //=====================================================
// File : action_lu_solve.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_LU_SOLVE
#define ACTION_LU_SOLVE
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_lu_solve
{
public :
static inline std::string name( void )
{
return "lu_solve_"+Interface::name();
}
static double nb_op_base(int size){
return 2.0*size*size*size/3.0; // questionable but not really important
}
static double calculate( int nb_calc, int size ) {
// STL matrix and vector initialization
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
init_matrix<pseudo_random>(A_stl,size);
init_vector<pseudo_random>(B_stl,size);
init_vector<null_function>(X_stl,size);
// generic matrix and vector initialization
typename Interface::gene_matrix A;
typename Interface::gene_vector B;
typename Interface::gene_vector X;
typename Interface::gene_matrix LU;
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X,X_stl);
Interface::matrix_from_stl(LU,A_stl);
// local variable :
typename Interface::Pivot_Vector pivot; // pivot vector
Interface::new_Pivot_Vector(pivot,size);
// timer utilities
Portable_Timer chronos;
// time measurement
chronos.start();
for (int ii=0;ii<nb_calc;ii++){
// LU factorization
Interface::copy_matrix(A,LU,size);
Interface::LU_factor(LU,pivot,size);
// LU solve
Interface::LU_solve(LU,pivot,B,X,size);
}
// Time stop
chronos.stop();
double time=chronos.user_time();
// check result :
typename Interface::stl_vector B_new_stl(size);
Interface::vector_to_stl(X,X_stl);
STL_interface<typename Interface::real_type>::matrix_vector_product(A_stl,X_stl,B_new_stl,size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(B_stl,B_new_stl);
if (error>1.e-5){
INFOS("WRONG CALCULATION...residual=" << error);
STL_interface<typename Interface::real_type>::display_vector(B_stl);
STL_interface<typename Interface::real_type>::display_vector(B_new_stl);
exit(0);
}
// deallocation and return time
Interface::free_matrix(A,size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_Pivot_Vector(pivot);
return time;
}
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/actions/action_ger.hh | .hh | 3,460 | 129 |
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ACTION_GER
#define ACTION_GER
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
using namespace std;
template<class Interface>
class Action_ger {
public :
// Ctor
BTL_DONT_INLINE Action_ger( int size ):_size(size)
{
MESSAGE("Action_ger Ctor");
// STL matrix and vector initialization
typename Interface::stl_matrix tmp;
init_matrix<pseudo_random>(A_stl,_size);
init_vector<pseudo_random>(B_stl,_size);
init_vector<pseudo_random>(X_stl,_size);
init_vector<null_function>(resu_stl,_size);
// generic matrix and vector initialization
Interface::matrix_from_stl(A_ref,A_stl);
Interface::matrix_from_stl(A,A_stl);
Interface::vector_from_stl(B_ref,B_stl);
Interface::vector_from_stl(B,B_stl);
Interface::vector_from_stl(X_ref,X_stl);
Interface::vector_from_stl(X,X_stl);
}
// invalidate copy ctor
Action_ger( const Action_ger & )
{
INFOS("illegal call to Action_ger Copy Ctor");
exit(1);
}
// Dtor
BTL_DONT_INLINE ~Action_ger( void ){
MESSAGE("Action_ger Dtor");
Interface::free_matrix(A,_size);
Interface::free_vector(B);
Interface::free_vector(X);
Interface::free_matrix(A_ref,_size);
Interface::free_vector(B_ref);
Interface::free_vector(X_ref);
}
// action name
static inline std::string name( void )
{
return "ger_" + Interface::name();
}
double nb_op_base( void ){
return 2.0*_size*_size;
}
BTL_DONT_INLINE void initialize( void ){
Interface::copy_matrix(A_ref,A,_size);
Interface::copy_vector(B_ref,B,_size);
Interface::copy_vector(X_ref,X,_size);
}
BTL_DONT_INLINE void calculate( void ) {
BTL_ASM_COMMENT("#begin ger");
Interface::ger(A,B,X,_size);
BTL_ASM_COMMENT("end ger");
}
BTL_DONT_INLINE void check_result( void ){
// calculation check
Interface::vector_to_stl(X,resu_stl);
STL_interface<typename Interface::real_type>::ger(A_stl,B_stl,X_stl,_size);
typename Interface::real_type error=
STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
if (error>1.e-3){
INFOS("WRONG CALCULATION...residual=" << error);
// exit(0);
}
}
private :
typename Interface::stl_matrix A_stl;
typename Interface::stl_vector B_stl;
typename Interface::stl_vector X_stl;
typename Interface::stl_vector resu_stl;
typename Interface::gene_matrix A_ref;
typename Interface::gene_vector B_ref;
typename Interface::gene_vector X_ref;
typename Interface::gene_matrix A;
typename Interface::gene_vector B;
typename Interface::gene_vector X;
int _size;
};
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/mk_gnuplot_script.sh | .sh | 1,850 | 69 | #! /bin/bash
WHAT=$1
DIR=$2
echo $WHAT script generation
cat $WHAT.hh > $WHAT.gnuplot
DATA_FILE=`find $DIR -name "*.dat" | grep $WHAT`
echo plot \\ >> $WHAT.gnuplot
for FILE in $DATA_FILE
do
LAST=$FILE
done
echo LAST=$LAST
for FILE in $DATA_FILE
do
if [ $FILE != $LAST ]
then
BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot
fi
done
BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot
#echo set term postscript color >> $WHAT.gnuplot
#echo set output "'"$WHAT.ps"'" >> $WHAT.gnuplot
echo set term pbm small color >> $WHAT.gnuplot
echo set output "'"$WHAT.ppm"'" >> $WHAT.gnuplot
echo plot \\ >> $WHAT.gnuplot
for FILE in $DATA_FILE
do
if [ $FILE != $LAST ]
then
BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot
fi
done
BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot
echo set term jpeg large >> $WHAT.gnuplot
echo set output "'"$WHAT.jpg"'" >> $WHAT.gnuplot
echo plot \\ >> $WHAT.gnuplot
for FILE in $DATA_FILE
do
if [ $FILE != $LAST ]
then
BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$FILE"'" title "'"$TITLE"'" ",\\" >> $WHAT.gnuplot
fi
done
BASE=${LAST##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$LAST"'" title "'"$TITLE"'" >> $WHAT.gnuplot
gnuplot -persist < $WHAT.gnuplot
rm $WHAT.gnuplot
| Shell |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/mk_new_gnuplot.sh | .sh | 1,742 | 55 | #!/bin/bash
WHAT=$1
DIR=$2
cat ../gnuplot_common_settings.hh > ${WHAT}.gnuplot
echo "set title " `grep ${WHAT} ../action_settings.txt | head -n 1 | cut -d ";" -f 2` >> $WHAT.gnuplot
echo "set xlabel " `grep ${WHAT} ../action_settings.txt | head -n 1 | cut -d ";" -f 3` " offset 0,0" >> $WHAT.gnuplot
echo "set xrange [" `grep ${WHAT} ../action_settings.txt | head -n 1 | cut -d ";" -f 4` "]" >> $WHAT.gnuplot
if [ $# > 3 ]; then
if [ "$3" == "tiny" ]; then
echo "set xrange [2:16]" >> $WHAT.gnuplot
echo "set nologscale" >> $WHAT.gnuplot
fi
fi
DATA_FILE=`cat ../order_lib`
echo set term postscript color rounded enhanced >> $WHAT.gnuplot
echo set output "'"../${DIR}/$WHAT.ps"'" >> $WHAT.gnuplot
# echo set term svg color rounded enhanced >> $WHAT.gnuplot
# echo "set terminal svg enhanced size 1000 1000 fname \"Times\" fsize 36" >> $WHAT.gnuplot
# echo set output "'"../${DIR}/$WHAT.svg"'" >> $WHAT.gnuplot
echo plot \\ >> $WHAT.gnuplot
for FILE in $DATA_FILE
do
LAST=$FILE
done
for FILE in $DATA_FILE
do
BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
echo "'"$FILE"'" `grep $TITLE ../perlib_plot_settings.txt | head -n 1 | cut -d ";" -f 2` "\\" >> $WHAT.gnuplot
if [ $FILE != $LAST ]
then
echo ", \\" >> $WHAT.gnuplot
fi
done
echo " " >> $WHAT.gnuplot
gnuplot -persist < $WHAT.gnuplot
rm $WHAT.gnuplot
ps2pdf ../${DIR}/$WHAT.ps ../${DIR}/$WHAT.pdf
convert -background white -density 120 -rotate 90 -resize 800 +dither -colors 256 -quality 0 ../${DIR}/$WHAT.ps -background white -flatten ../${DIR}/$WHAT.png
# pstoedit -rotate -90 -xscale 0.8 -yscale 0.8 -centered -yshift -50 -xshift -100 -f plot-svg aat.ps aat2.svg
| Shell |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/gnuplot_common_settings.hh | .hh | 2,224 | 88 | set noclip points
set clip one
set noclip two
set bar 1.000000
set border 31 lt -1 lw 1.000
set xdata
set ydata
set zdata
set x2data
set y2data
set boxwidth
set dummy x,y
set format x "%g"
set format y "%g"
set format x2 "%g"
set format y2 "%g"
set format z "%g"
set angles radians
set nogrid
set key title ""
set key left top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0
set nolabel
set noarrow
# set nolinestyle # deprecated
set nologscale
set logscale x 10
set offsets 0, 0, 0, 0
set pointsize 1
set encoding default
set nopolar
set noparametric
set view 60, 30, 1, 1
set samples 100, 100
set isosamples 10, 10
set surface
set nocontour
set clabel '%8.3g'
set mapping cartesian
set nohidden3d
set cntrparam order 4
set cntrparam linear
set cntrparam levels auto 5
set cntrparam points 5
set size ratio 0 1,1
set origin 0,0
# set data style lines
# set function style lines
set xzeroaxis lt -2 lw 1.000
set x2zeroaxis lt -2 lw 1.000
set yzeroaxis lt -2 lw 1.000
set y2zeroaxis lt -2 lw 1.000
set tics in
set ticslevel 0.5
set tics scale 1, 0.5
set mxtics default
set mytics default
set mx2tics default
set my2tics default
set xtics border mirror norotate autofreq
set ytics border mirror norotate autofreq
set ztics border nomirror norotate autofreq
set nox2tics
set noy2tics
set timestamp "" bottom norotate offset 0,0
set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] )
set trange [ * : * ] noreverse nowriteback # (currently [-5:5] )
set urange [ * : * ] noreverse nowriteback # (currently [-5:5] )
set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] )
set xlabel "matrix size" offset 0,0
set x2label "" offset 0,0
set timefmt "%d/%m/%y\n%H:%M"
set xrange [ 10 : 1000 ] noreverse nowriteback
set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] )
set ylabel "MFLOPS" offset 0,0
set y2label "" offset 0,0
set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] )
set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] )
set zlabel "" offset 0,0
set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] )
set zero 1e-08
set lmargin -1
set bmargin -1
set rmargin -1
set tmargin -1
set locale "C"
set xrange [4:1024]
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/regularize.cxx | .cxx | 3,425 | 132 | //=====================================================
// File : regularize.cxx
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "utilities.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include "bench_parameter.hh"
#include <set>
using namespace std;
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
void regularize_curve(const string & filename,
const vector<double> & tab_mflops,
const vector<int> & tab_sizes,
int start_cut_size, int stop_cut_size);
/////////////////////////////////////////////////////////////////////////////////////////////////
int main( int argc , char *argv[] )
{
// input data
if (argc<4){
INFOS("!!! Error ... usage : main filename start_cut_size stop_cut_size regularize_filename");
exit(0);
}
INFOS(argc);
int start_cut_size=atoi(argv[2]);
int stop_cut_size=atoi(argv[3]);
string filename=argv[1];
string regularize_filename=argv[4];
INFOS(filename);
INFOS("start_cut_size="<<start_cut_size);
vector<int> tab_sizes;
vector<double> tab_mflops;
read_xy_file(filename,tab_sizes,tab_mflops);
// regularizeing
regularize_curve(regularize_filename,tab_mflops,tab_sizes,start_cut_size,stop_cut_size);
}
//////////////////////////////////////////////////////////////////////////////////////
void regularize_curve(const string & filename,
const vector<double> & tab_mflops,
const vector<int> & tab_sizes,
int start_cut_size, int stop_cut_size)
{
int size=tab_mflops.size();
ofstream output_file (filename.c_str(),ios::out) ;
int i=0;
while(tab_sizes[i]<start_cut_size){
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
i++;
}
output_file << endl ;
while(tab_sizes[i]<stop_cut_size){
i++;
}
while(i<size){
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
i++;
}
output_file.close();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
ifstream input_file (filename.c_str(),ios::in) ;
if (!input_file){
INFOS("!!! Error opening "<<filename);
exit(0);
}
int nb_point=0;
int size=0;
double mflops=0;
while (input_file >> size >> mflops ){
nb_point++;
tab_sizes.push_back(size);
tab_mflops.push_back(mflops);
}
SCRUTE(nb_point);
input_file.close();
}
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/mk_mean_script.sh | .sh | 929 | 53 | #! /bin/bash
WHAT=$1
DIR=$2
MINIC=$3
MAXIC=$4
MINOC=$5
MAXOC=$6
prefix=$8
meanstatsfilename=$2/mean.html
WORK_DIR=tmp
mkdir $WORK_DIR
DATA_FILE=`find $DIR -name "*.dat" | grep _${WHAT}`
if [ -n "$DATA_FILE" ]; then
echo ""
echo "$1..."
for FILE in $DATA_FILE
do
##echo hello world
##echo "mk_mean_script1" ${FILE}
BASE=${FILE##*/} ; BASE=${FILE##*/} ; AVANT=bench_${WHAT}_ ; REDUC=${BASE##*$AVANT} ; TITLE=${REDUC%.dat}
##echo "mk_mean_script1" ${TITLE}
cp $FILE ${WORK_DIR}/${TITLE}
done
cd $WORK_DIR
../main $1 $3 $4 $5 $6 * >> ../$meanstatsfilename
../mk_new_gnuplot.sh $1 $2 $7
rm -f *.gnuplot
cd ..
echo '<br/>' >> $meanstatsfilename
webpagefilename=$2/index.html
# echo '<h3>'${WHAT}'</h3>' >> $webpagefilename
echo '<hr/><a href="'$prefix$1'.pdf"><img src="'$prefix$1'.png" alt="'${WHAT}'" /></a><br/>' >> $webpagefilename
fi
rm -R $WORK_DIR
| Shell |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/mean.cxx | .cxx | 5,306 | 183 | //=====================================================
// File : mean.cxx
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "utilities.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include "bench_parameter.hh"
#include "utils/xy_file.hh"
#include <set>
using namespace std;
double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max);
class Lib_Mean{
public:
Lib_Mean( void ):_lib_name(),_mean_in_cache(),_mean_out_of_cache(){
MESSAGE("Lib_mean Default Ctor");
MESSAGE("!!! should not be used");
exit(0);
}
Lib_Mean(const string & name, const double & mic, const double & moc):_lib_name(name),_mean_in_cache(mic),_mean_out_of_cache(moc){
MESSAGE("Lib_mean Ctor");
}
Lib_Mean(const Lib_Mean & lm):_lib_name(lm._lib_name),_mean_in_cache(lm._mean_in_cache),_mean_out_of_cache(lm._mean_out_of_cache){
MESSAGE("Lib_mean Copy Ctor");
}
~Lib_Mean( void ){
MESSAGE("Lib_mean Dtor");
}
double _mean_in_cache;
double _mean_out_of_cache;
string _lib_name;
bool operator < ( const Lib_Mean &right) const
{
//return ( this->_mean_out_of_cache > right._mean_out_of_cache) ;
return ( this->_mean_in_cache > right._mean_in_cache) ;
}
};
int main( int argc , char *argv[] )
{
if (argc<6){
INFOS("!!! Error ... usage : main what mic Mic moc Moc filename1 finename2...");
exit(0);
}
INFOS(argc);
int min_in_cache=atoi(argv[2]);
int max_in_cache=atoi(argv[3]);
int min_out_of_cache=atoi(argv[4]);
int max_out_of_cache=atoi(argv[5]);
multiset<Lib_Mean> s_lib_mean ;
for (int i=6;i<argc;i++){
string filename=argv[i];
INFOS(filename);
double mic=0;
double moc=0;
{
vector<int> tab_sizes;
vector<double> tab_mflops;
read_xy_file(filename,tab_sizes,tab_mflops);
mic=mean_calc(tab_sizes,tab_mflops,min_in_cache,max_in_cache);
moc=mean_calc(tab_sizes,tab_mflops,min_out_of_cache,max_out_of_cache);
Lib_Mean cur_lib_mean(filename,mic,moc);
s_lib_mean.insert(cur_lib_mean);
}
}
cout << "<TABLE BORDER CELLPADDING=2>" << endl ;
cout << " <TR>" << endl ;
cout << " <TH ALIGN=CENTER> " << argv[1] << " </TH>" << endl ;
cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> in cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
cout << " <TH ALIGN=CENTER> in cache <BR> % best </TH>" << endl ;
cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> out of cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
cout << " <TH ALIGN=CENTER> out of cache <BR> % best </TH>" << endl ;
cout << " <TH ALIGN=CENTER> details </TH>" << endl ;
cout << " <TH ALIGN=CENTER> comments </TH>" << endl ;
cout << " </TR>" << endl ;
multiset<Lib_Mean>::iterator is = s_lib_mean.begin();
Lib_Mean best(*is);
for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
cout << " <TR>" << endl ;
cout << " <TD> " << is->_lib_name << " </TD>" << endl ;
cout << " <TD> " << is->_mean_in_cache << " </TD>" << endl ;
cout << " <TD> " << 100*(is->_mean_in_cache/best._mean_in_cache) << " </TD>" << endl ;
cout << " <TD> " << is->_mean_out_of_cache << " </TD>" << endl ;
cout << " <TD> " << 100*(is->_mean_out_of_cache/best._mean_out_of_cache) << " </TD>" << endl ;
cout << " <TD> " <<
"<a href=\"#"<<is->_lib_name<<"_"<<argv[1]<<"\">snippet</a>/"
"<a href=\"#"<<is->_lib_name<<"_flags\">flags</a> </TD>" << endl ;
cout << " <TD> " <<
"<a href=\"#"<<is->_lib_name<<"_comments\">click here</a> </TD>" << endl ;
cout << " </TR>" << endl ;
}
cout << "</TABLE>" << endl ;
ofstream output_file ("../order_lib",ios::out) ;
for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
output_file << is->_lib_name << endl ;
}
output_file.close();
}
double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max){
int size=tab_sizes.size();
int nb_sample=0;
double mean=0.0;
for (int i=0;i<size;i++){
if ((tab_sizes[i]>=size_min)&&(tab_sizes[i]<=size_max)){
nb_sample++;
mean+=tab_mflops[i];
}
}
if (nb_sample==0){
INFOS("no data for mean calculation");
return 0.0;
}
return mean/nb_sample;
}
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/smooth.cxx | .cxx | 5,112 | 199 | //=====================================================
// File : smooth.cxx
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002
//=====================================================
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "utilities.h"
#include <vector>
#include <deque>
#include <string>
#include <iostream>
#include <fstream>
#include "bench_parameter.hh"
#include <set>
using namespace std;
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
void write_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
void smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width);
void centered_smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width);
/////////////////////////////////////////////////////////////////////////////////////////////////
int main( int argc , char *argv[] )
{
// input data
if (argc<3){
INFOS("!!! Error ... usage : main filename window_half_width smooth_filename");
exit(0);
}
INFOS(argc);
int window_half_width=atoi(argv[2]);
string filename=argv[1];
string smooth_filename=argv[3];
INFOS(filename);
INFOS("window_half_width="<<window_half_width);
vector<int> tab_sizes;
vector<double> tab_mflops;
read_xy_file(filename,tab_sizes,tab_mflops);
// smoothing
vector<double> smooth_tab_mflops;
//smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
centered_smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
// output result
write_xy_file(smooth_filename,tab_sizes,smooth_tab_mflops);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class VECTOR>
double weighted_mean(const VECTOR & data)
{
double mean=0.0;
for (int i=0 ; i<data.size() ; i++){
mean+=data[i];
}
return mean/double(data.size()) ;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width){
int window_width=2*window_half_width+1;
int size=tab_mflops.size();
vector<double> sample(window_width);
for (int i=0 ; i < size ; i++){
for ( int j=0 ; j < window_width ; j++ ){
int shifted_index=i+j-window_half_width;
if (shifted_index<0) shifted_index=0;
if (shifted_index>size-1) shifted_index=size-1;
sample[j]=tab_mflops[shifted_index];
}
smooth_tab_mflops.push_back(weighted_mean(sample));
}
}
void centered_smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width){
int max_window_width=2*window_half_width+1;
int size=tab_mflops.size();
for (int i=0 ; i < size ; i++){
deque<double> sample;
sample.push_back(tab_mflops[i]);
for ( int j=1 ; j <= window_half_width ; j++ ){
int before=i-j;
int after=i+j;
if ((before>=0)&&(after<size)) // inside of the vector
{
sample.push_front(tab_mflops[before]);
sample.push_back(tab_mflops[after]);
}
}
smooth_tab_mflops.push_back(weighted_mean(sample));
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void write_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
ofstream output_file (filename.c_str(),ios::out) ;
for (int i=0 ; i < tab_sizes.size() ; i++)
{
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
}
output_file.close();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
ifstream input_file (filename.c_str(),ios::in) ;
if (!input_file){
INFOS("!!! Error opening "<<filename);
exit(0);
}
int nb_point=0;
int size=0;
double mflops=0;
while (input_file >> size >> mflops ){
nb_point++;
tab_sizes.push_back(size);
tab_mflops.push_back(mflops);
}
SCRUTE(nb_point);
input_file.close();
}
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/btl/data/smooth_all.sh | .sh | 1,687 | 69 | #! /bin/bash
ORIG_DIR=$1
SMOOTH_DIR=${ORIG_DIR}_smooth
mkdir ${SMOOTH_DIR}
AXPY_FILE=`find ${ORIG_DIR} -name "*.dat" | grep axpy`
for FILE in ${AXPY_FILE}
do
echo $FILE
BASE=${FILE##*/}
./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}_tmp
./regularize ${SMOOTH_DIR}/${BASE}_tmp 2500 15000 ${SMOOTH_DIR}/${BASE}
rm -f ${SMOOTH_DIR}/${BASE}_tmp
done
MATRIX_VECTOR_FILE=`find ${ORIG_DIR} -name "*.dat" | grep matrix_vector`
for FILE in ${MATRIX_VECTOR_FILE}
do
echo $FILE
BASE=${FILE##*/}
./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}_tmp
./regularize ${SMOOTH_DIR}/${BASE}_tmp 50 180 ${SMOOTH_DIR}/${BASE}
rm -f ${SMOOTH_DIR}/${BASE}_tmp
done
MATRIX_MATRIX_FILE=`find ${ORIG_DIR} -name "*.dat" | grep matrix_matrix`
for FILE in ${MATRIX_MATRIX_FILE}
do
echo $FILE
BASE=${FILE##*/}
./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}
done
AAT_FILE=`find ${ORIG_DIR} -name "*.dat" | grep _aat`
for FILE in ${AAT_FILE}
do
echo $FILE
BASE=${FILE##*/}
./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}
done
ATA_FILE=`find ${ORIG_DIR} -name "*.dat" | grep _ata`
for FILE in ${ATA_FILE}
do
echo $FILE
BASE=${FILE##*/}
./smooth ${ORIG_DIR}/${BASE} 4 ${SMOOTH_DIR}/${BASE}
done
### no smoothing for tinyvector and matrices libs
TINY_BLITZ_FILE=`find ${ORIG_DIR} -name "*.dat" | grep tiny_blitz`
for FILE in ${TINY_BLITZ_FILE}
do
echo $FILE
BASE=${FILE##*/}
cp ${ORIG_DIR}/${BASE} ${SMOOTH_DIR}/${BASE}
done
TVMET_FILE=`find ${ORIG_DIR} -name "*.dat" | grep tvmet`
for FILE in ${TVMET_FILE}
do
echo $FILE
BASE=${FILE##*/}
cp ${ORIG_DIR}/${BASE} ${SMOOTH_DIR}/${BASE}
done
| Shell |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/perf_monitoring/gemm/lazy_gemm.cpp | .cpp | 2,368 | 99 | #include <iostream>
#include <fstream>
#include <vector>
#include <Eigen/Core>
#include "../../BenchTimer.h"
using namespace Eigen;
#ifndef SCALAR
#error SCALAR must be defined
#endif
typedef SCALAR Scalar;
template<typename MatA, typename MatB, typename MatC>
EIGEN_DONT_INLINE
void lazy_gemm(const MatA &A, const MatB &B, MatC &C)
{
// escape((void*)A.data());
// escape((void*)B.data());
C.noalias() += A.lazyProduct(B);
// escape((void*)C.data());
}
template<int m, int n, int k, int TA>
EIGEN_DONT_INLINE
double bench()
{
typedef Matrix<Scalar,m,k,TA> MatA;
typedef Matrix<Scalar,k,n> MatB;
typedef Matrix<Scalar,m,n> MatC;
MatA A(m,k);
MatB B(k,n);
MatC C(m,n);
A.setRandom();
B.setRandom();
C.setZero();
BenchTimer t;
double up = 1e7*4/sizeof(Scalar);
double tm0 = 10, tm1 = 20;
double flops = 2. * m * n * k;
long rep = std::max(10., std::min(10000., up/flops) );
long tries = std::max(tm0, std::min(tm1, up/flops) );
BENCH(t, tries, rep, lazy_gemm(A,B,C));
return 1e-9 * rep * flops / t.best();
}
template<int m, int n, int k>
double bench_t(int t)
{
if(t)
return bench<m,n,k,RowMajor>();
else
return bench<m,n,k,0>();
}
EIGEN_DONT_INLINE
double bench_mnk(int m, int n, int k, int t)
{
int id = m*10000 + n*100 + k;
switch(id) {
case 10101 : return bench_t< 1, 1, 1>(t); break;
case 20202 : return bench_t< 2, 2, 2>(t); break;
case 30303 : return bench_t< 3, 3, 3>(t); break;
case 40404 : return bench_t< 4, 4, 4>(t); break;
case 50505 : return bench_t< 5, 5, 5>(t); break;
case 60606 : return bench_t< 6, 6, 6>(t); break;
case 70707 : return bench_t< 7, 7, 7>(t); break;
case 80808 : return bench_t< 8, 8, 8>(t); break;
case 90909 : return bench_t< 9, 9, 9>(t); break;
case 101010 : return bench_t<10,10,10>(t); break;
case 111111 : return bench_t<11,11,11>(t); break;
case 121212 : return bench_t<12,12,12>(t); break;
}
return 0;
}
int main(int argc, char **argv)
{
std::vector<double> results;
std::ifstream settings("lazy_gemm_settings.txt");
long m, n, k, t;
while(settings >> m >> n >> k >> t)
{
//std::cerr << " Testing " << m << " " << n << " " << k << std::endl;
results.push_back( bench_mnk(m, n, k, t) );
}
std::cout << RowVectorXd::Map(results.data(), results.size());
return 0;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/perf_monitoring/gemm/make_plot.sh | .sh | 991 | 38 | #!/bin/bash
# base name of the bench
# it reads $1.out
# and generates $1.pdf
WHAT=$1
bench=$2
header="rev "
while read line
do
if [ ! -z '$line' ]; then
header="$header \"$line\""
fi
done < $bench"_settings.txt"
echo $header > $WHAT.out.header
cat $WHAT.out >> $WHAT.out.header
echo "set title '$WHAT'" > $WHAT.gnuplot
echo "set key autotitle columnhead outside " >> $WHAT.gnuplot
echo "set xtics rotate 1" >> $WHAT.gnuplot
echo "set term pdf color rounded enhanced fontscale 0.35 size 7in,5in" >> $WHAT.gnuplot
echo set output "'"$WHAT.pdf"'" >> $WHAT.gnuplot
col=`cat $bench"_settings.txt" | wc -l`
echo "plot for [col=2:$col+1] '$WHAT.out.header' using 0:col:xticlabels(1) with lines" >> $WHAT.gnuplot
echo " " >> $WHAT.gnuplot
gnuplot -persist < $WHAT.gnuplot
# generate a png file
# convert -background white -density 120 -rotate 90 -resize 800 +dither -colors 256 -quality 0 $WHAT.ps -background white -flatten .$WHAT.png
# clean
rm $WHAT.out.header $WHAT.gnuplot | Shell |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/perf_monitoring/gemm/run.sh | .sh | 3,290 | 157 | #!/bin/bash
# ./run.sh gemm
# ./run.sh lazy_gemm
# Examples of environment variables to be set:
# PREFIX="haswell-fma-"
# CXX_FLAGS="-mfma"
# Options:
# -up : enforce the recomputation of existing data, and keep best results as a merging strategy
# -s : recompute selected changesets only and keep bests
bench=$1
if echo "$*" | grep '\-up' > /dev/null; then
update=true
else
update=false
fi
if echo "$*" | grep '\-s' > /dev/null; then
selected=true
else
selected=false
fi
global_args="$*"
if [ $selected == true ]; then
echo "Recompute selected changesets only and keep bests"
elif [ $update == true ]; then
echo "(Re-)Compute all changesets and keep bests"
else
echo "Skip previously computed changesets"
fi
if [ ! -d "eigen_src" ]; then
hg clone https://bitbucket.org/eigen/eigen eigen_src
else
cd eigen_src
hg pull -u
cd ..
fi
if [ ! -z '$CXX' ]; then
CXX=g++
fi
function make_backup
{
if [ -f "$1.out" ]; then
mv "$1.out" "$1.backup"
fi
}
function merge
{
count1=`echo $1 | wc -w`
count2=`echo $2 | wc -w`
if [ $count1 == $count2 ]; then
a=( $1 ); b=( $2 )
res=""
for (( i=0 ; i<$count1 ; i++ )); do
ai=${a[$i]}; bi=${b[$i]}
tmp=`echo "if ($ai > $bi) $ai else $bi " | bc -l`
res="$res $tmp"
done
echo $res
else
echo $1
fi
}
function test_current
{
rev=$1
scalar=$2
name=$3
prev=""
if [ -e "$name.backup" ]; then
prev=`grep $rev "$name.backup" | cut -c 14-`
fi
res=$prev
count_rev=`echo $prev | wc -w`
count_ref=`cat $bench"_settings.txt" | wc -l`
if echo "$global_args" | grep "$rev" > /dev/null; then
rev_found=true
else
rev_found=false
fi
# echo $update et $selected et $rev_found because $rev et "$global_args"
# echo $count_rev et $count_ref
if [ $update == true ] || [ $count_rev != $count_ref ] || ([ $selected == true ] && [ $rev_found == true ]); then
if $CXX -O2 -DNDEBUG -march=native $CXX_FLAGS -I eigen_src $bench.cpp -DSCALAR=$scalar -o $name; then
curr=`./$name`
if [ $count_rev == $count_ref ]; then
echo "merge previous $prev"
echo "with new $curr"
else
echo "got $curr"
fi
res=`merge "$curr" "$prev"`
# echo $res
echo "$rev $res" >> $name.out
else
echo "Compilation failed, skip rev $rev"
fi
else
echo "Skip existing results for $rev / $name"
echo "$rev $res" >> $name.out
fi
}
make_backup $PREFIX"s"$bench
make_backup $PREFIX"d"$bench
make_backup $PREFIX"c"$bench
cut -f1 -d"#" < changesets.txt | grep -E '[[:alnum:]]' | while read rev
do
if [ ! -z '$rev' ]; then
echo "Testing rev $rev"
cd eigen_src
hg up -C $rev > /dev/null
actual_rev=`hg identify | cut -f1 -d' '`
cd ..
test_current $actual_rev float $PREFIX"s"$bench
test_current $actual_rev double $PREFIX"d"$bench
test_current $actual_rev "std::complex<double>" $PREFIX"c"$bench
fi
done
echo "Float:"
cat $PREFIX"s""$bench.out"
echo " "
echo "Double:"
cat $PREFIX"d""$bench.out"
echo ""
echo "Complex:"
cat $PREFIX"c""$bench.out"
echo ""
./make_plot.sh $PREFIX"s"$bench $bench
./make_plot.sh $PREFIX"d"$bench $bench
./make_plot.sh $PREFIX"c"$bench $bench
| Shell |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/perf_monitoring/gemm/gemm.cpp | .cpp | 1,269 | 68 | #include <iostream>
#include <fstream>
#include <vector>
#include <Eigen/Core>
#include "../../BenchTimer.h"
using namespace Eigen;
#ifndef SCALAR
#error SCALAR must be defined
#endif
typedef SCALAR Scalar;
typedef Matrix<Scalar,Dynamic,Dynamic> Mat;
EIGEN_DONT_INLINE
void gemm(const Mat &A, const Mat &B, Mat &C)
{
C.noalias() += A * B;
}
EIGEN_DONT_INLINE
double bench(long m, long n, long k)
{
Mat A(m,k);
Mat B(k,n);
Mat C(m,n);
A.setRandom();
B.setRandom();
C.setZero();
BenchTimer t;
double up = 1e8*4/sizeof(Scalar);
double tm0 = 4, tm1 = 10;
if(NumTraits<Scalar>::IsComplex)
{
up /= 4;
tm0 = 2;
tm1 = 4;
}
double flops = 2. * m * n * k;
long rep = std::max(1., std::min(100., up/flops) );
long tries = std::max(tm0, std::min(tm1, up/flops) );
BENCH(t, tries, rep, gemm(A,B,C));
return 1e-9 * rep * flops / t.best();
}
int main(int argc, char **argv)
{
std::vector<double> results;
std::ifstream settings("gemm_settings.txt");
long m, n, k;
while(settings >> m >> n >> k)
{
//std::cerr << " Testing " << m << " " << n << " " << k << std::endl;
results.push_back( bench(m, n, k) );
}
std::cout << RowVectorXd::Map(results.data(), results.size());
return 0;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/tensors/benchmark_main.cc | .cc | 6,834 | 238 | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "benchmark.h"
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <inttypes.h>
#include <time.h>
#include <map>
static int64_t g_flops_processed;
static int64_t g_benchmark_total_time_ns;
static int64_t g_benchmark_start_time_ns;
typedef std::map<std::string, ::testing::Benchmark*> BenchmarkMap;
typedef BenchmarkMap::iterator BenchmarkMapIt;
BenchmarkMap& gBenchmarks() {
static BenchmarkMap g_benchmarks;
return g_benchmarks;
}
static int g_name_column_width = 20;
static int Round(int n) {
int base = 1;
while (base*10 < n) {
base *= 10;
}
if (n < 2*base) {
return 2*base;
}
if (n < 5*base) {
return 5*base;
}
return 10*base;
}
#ifdef __APPLE__
#include <mach/mach_time.h>
static mach_timebase_info_data_t g_time_info;
static void __attribute__((constructor)) init_info() {
mach_timebase_info(&g_time_info);
}
#endif
static int64_t NanoTime() {
#if defined(__APPLE__)
uint64_t t = mach_absolute_time();
return t * g_time_info.numer / g_time_info.denom;
#else
struct timespec t;
t.tv_sec = t.tv_nsec = 0;
clock_gettime(CLOCK_MONOTONIC, &t);
return static_cast<int64_t>(t.tv_sec) * 1000000000LL + t.tv_nsec;
#endif
}
namespace testing {
Benchmark* Benchmark::Arg(int arg) {
args_.push_back(arg);
return this;
}
Benchmark* Benchmark::Range(int lo, int hi) {
const int kRangeMultiplier = 8;
if (hi < lo) {
int temp = hi;
hi = lo;
lo = temp;
}
while (lo < hi) {
args_.push_back(lo);
lo *= kRangeMultiplier;
}
// We always run the hi number.
args_.push_back(hi);
return this;
}
const char* Benchmark::Name() {
return name_;
}
bool Benchmark::ShouldRun(int argc, char* argv[]) {
if (argc == 1) {
return true; // With no arguments, we run all benchmarks.
}
// Otherwise, we interpret each argument as a regular expression and
// see if any of our benchmarks match.
for (int i = 1; i < argc; i++) {
regex_t re;
if (regcomp(&re, argv[i], 0) != 0) {
fprintf(stderr, "couldn't compile \"%s\" as a regular expression!\n", argv[i]);
exit(EXIT_FAILURE);
}
int match = regexec(&re, name_, 0, NULL, 0);
regfree(&re);
if (match != REG_NOMATCH) {
return true;
}
}
return false;
}
void Benchmark::Register(const char* name, void (*fn)(int), void (*fn_range)(int, int)) {
name_ = name;
fn_ = fn;
fn_range_ = fn_range;
if (fn_ == NULL && fn_range_ == NULL) {
fprintf(stderr, "%s: missing function\n", name_);
exit(EXIT_FAILURE);
}
gBenchmarks().insert(std::make_pair(name, this));
}
void Benchmark::Run() {
if (fn_ != NULL) {
RunWithArg(0);
} else {
if (args_.empty()) {
fprintf(stderr, "%s: no args!\n", name_);
exit(EXIT_FAILURE);
}
for (size_t i = 0; i < args_.size(); ++i) {
RunWithArg(args_[i]);
}
}
}
void Benchmark::RunRepeatedlyWithArg(int iterations, int arg) {
g_flops_processed = 0;
g_benchmark_total_time_ns = 0;
g_benchmark_start_time_ns = NanoTime();
if (fn_ != NULL) {
fn_(iterations);
} else {
fn_range_(iterations, arg);
}
if (g_benchmark_start_time_ns != 0) {
g_benchmark_total_time_ns += NanoTime() - g_benchmark_start_time_ns;
}
}
void Benchmark::RunWithArg(int arg) {
// run once in case it's expensive
int iterations = 1;
RunRepeatedlyWithArg(iterations, arg);
while (g_benchmark_total_time_ns < 1e9 && iterations < 1e9) {
int last = iterations;
if (g_benchmark_total_time_ns/iterations == 0) {
iterations = 1e9;
} else {
iterations = 1e9 / (g_benchmark_total_time_ns/iterations);
}
iterations = std::max(last + 1, std::min(iterations + iterations/2, 100*last));
iterations = Round(iterations);
RunRepeatedlyWithArg(iterations, arg);
}
char throughput[100];
throughput[0] = '\0';
if (g_benchmark_total_time_ns > 0 && g_flops_processed > 0) {
double mflops_processed = static_cast<double>(g_flops_processed)/1e6;
double seconds = static_cast<double>(g_benchmark_total_time_ns)/1e9;
snprintf(throughput, sizeof(throughput), " %8.2f MFlops/s", mflops_processed/seconds);
}
char full_name[100];
if (fn_range_ != NULL) {
if (arg >= (1<<20)) {
snprintf(full_name, sizeof(full_name), "%s/%dM", name_, arg/(1<<20));
} else if (arg >= (1<<10)) {
snprintf(full_name, sizeof(full_name), "%s/%dK", name_, arg/(1<<10));
} else {
snprintf(full_name, sizeof(full_name), "%s/%d", name_, arg);
}
} else {
snprintf(full_name, sizeof(full_name), "%s", name_);
}
printf("%-*s %10d %10" PRId64 "%s\n", g_name_column_width, full_name,
iterations, g_benchmark_total_time_ns/iterations, throughput);
fflush(stdout);
}
} // namespace testing
void SetBenchmarkFlopsProcessed(int64_t x) {
g_flops_processed = x;
}
void StopBenchmarkTiming() {
if (g_benchmark_start_time_ns != 0) {
g_benchmark_total_time_ns += NanoTime() - g_benchmark_start_time_ns;
}
g_benchmark_start_time_ns = 0;
}
void StartBenchmarkTiming() {
if (g_benchmark_start_time_ns == 0) {
g_benchmark_start_time_ns = NanoTime();
}
}
int main(int argc, char* argv[]) {
if (gBenchmarks().empty()) {
fprintf(stderr, "No benchmarks registered!\n");
exit(EXIT_FAILURE);
}
for (BenchmarkMapIt it = gBenchmarks().begin(); it != gBenchmarks().end(); ++it) {
int name_width = static_cast<int>(strlen(it->second->Name()));
g_name_column_width = std::max(g_name_column_width, name_width);
}
bool need_header = true;
for (BenchmarkMapIt it = gBenchmarks().begin(); it != gBenchmarks().end(); ++it) {
::testing::Benchmark* b = it->second;
if (b->ShouldRun(argc, argv)) {
if (need_header) {
printf("%-*s %10s %10s\n", g_name_column_width, "", "iterations", "ns/op");
fflush(stdout);
need_header = false;
}
b->Run();
}
}
if (need_header) {
fprintf(stderr, "No matching benchmarks!\n");
fprintf(stderr, "Available benchmarks:\n");
for (BenchmarkMapIt it = gBenchmarks().begin(); it != gBenchmarks().end(); ++it) {
fprintf(stderr, " %s\n", it->second->Name());
}
exit(EXIT_FAILURE);
}
return 0;
}
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/tensors/contraction_benchmarks_cpu.cc | .cc | 1,389 | 40 | #define EIGEN_USE_THREADS
#include <string>
#include "tensor_benchmarks.h"
#define CREATE_THREAD_POOL(threads) \
Eigen::ThreadPool pool(threads); \
Eigen::ThreadPoolDevice device(&pool, threads);
// Contractions for number of threads ranging from 1 to 32
// Dimensions are Rows, Cols, Depth
#define BM_ContractionCPU(D1, D2, D3) \
static void BM_##Contraction##_##D1##x##D2##x##D3(int iters, int Threads) { \
StopBenchmarkTiming(); \
CREATE_THREAD_POOL(Threads); \
BenchmarkSuite<Eigen::ThreadPoolDevice, float> suite(device, D1, D2, D3); \
suite.contraction(iters); \
} \
BENCHMARK_RANGE(BM_##Contraction##_##D1##x##D2##x##D3, 1, 32);
// Vector Matrix and Matrix Vector products
BM_ContractionCPU(1, 2000, 500);
BM_ContractionCPU(2000, 1, 500);
// Various skinny matrices
BM_ContractionCPU(250, 3, 512);
BM_ContractionCPU(1500, 3, 512);
BM_ContractionCPU(512, 800, 4);
BM_ContractionCPU(512, 80, 800);
BM_ContractionCPU(512, 80, 13522);
BM_ContractionCPU(1, 80, 13522);
BM_ContractionCPU(3200, 512, 4);
BM_ContractionCPU(3200, 512, 80);
BM_ContractionCPU(3200, 80, 512);
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/tensors/tensor_benchmarks_cpu.cc | .cc | 6,264 | 169 | #define EIGEN_USE_THREADS
#include <string>
#include "tensor_benchmarks.h"
#define CREATE_THREAD_POOL(threads) \
Eigen::ThreadPool pool(threads); \
Eigen::ThreadPoolDevice device(&pool, threads);
// Simple functions
#define BM_FuncCPU(FUNC, THREADS) \
static void BM_##FUNC##_##THREADS##T(int iters, int N) { \
StopBenchmarkTiming(); \
CREATE_THREAD_POOL(THREADS); \
BenchmarkSuite<Eigen::ThreadPoolDevice, float> suite(device, N); \
suite.FUNC(iters); \
} \
BENCHMARK_RANGE(BM_##FUNC##_##THREADS##T, 10, 5000);
BM_FuncCPU(memcpy, 4);
BM_FuncCPU(memcpy, 8);
BM_FuncCPU(memcpy, 12);
BM_FuncCPU(typeCasting, 4);
BM_FuncCPU(typeCasting, 8);
BM_FuncCPU(typeCasting, 12);
BM_FuncCPU(random, 4);
BM_FuncCPU(random, 8);
BM_FuncCPU(random, 12);
BM_FuncCPU(slicing, 4);
BM_FuncCPU(slicing, 8);
BM_FuncCPU(slicing, 12);
BM_FuncCPU(rowChip, 4);
BM_FuncCPU(rowChip, 8);
BM_FuncCPU(rowChip, 12);
BM_FuncCPU(colChip, 4);
BM_FuncCPU(colChip, 8);
BM_FuncCPU(colChip, 12);
BM_FuncCPU(shuffling, 4);
BM_FuncCPU(shuffling, 8);
BM_FuncCPU(shuffling, 12);
BM_FuncCPU(padding, 4);
BM_FuncCPU(padding, 8);
BM_FuncCPU(padding, 12);
BM_FuncCPU(striding, 4);
BM_FuncCPU(striding, 8);
BM_FuncCPU(striding, 12);
BM_FuncCPU(broadcasting, 4);
BM_FuncCPU(broadcasting, 8);
BM_FuncCPU(broadcasting, 12);
BM_FuncCPU(coeffWiseOp, 4);
BM_FuncCPU(coeffWiseOp, 8);
BM_FuncCPU(coeffWiseOp, 12);
BM_FuncCPU(algebraicFunc, 4);
BM_FuncCPU(algebraicFunc, 8);
BM_FuncCPU(algebraicFunc, 12);
BM_FuncCPU(transcendentalFunc, 4);
BM_FuncCPU(transcendentalFunc, 8);
BM_FuncCPU(transcendentalFunc, 12);
BM_FuncCPU(rowReduction, 4);
BM_FuncCPU(rowReduction, 8);
BM_FuncCPU(rowReduction, 12);
BM_FuncCPU(colReduction, 4);
BM_FuncCPU(colReduction, 8);
BM_FuncCPU(colReduction, 12);
// Contractions
#define BM_FuncWithInputDimsCPU(FUNC, D1, D2, D3, THREADS) \
static void BM_##FUNC##_##D1##x##D2##x##D3##_##THREADS##T(int iters, int N) { \
StopBenchmarkTiming(); \
if (THREADS == 1) { \
Eigen::DefaultDevice device; \
BenchmarkSuite<Eigen::DefaultDevice, float> suite(device, D1, D2, D3); \
suite.FUNC(iters); \
} else { \
CREATE_THREAD_POOL(THREADS); \
BenchmarkSuite<Eigen::ThreadPoolDevice, float> suite(device, D1, D2, D3); \
suite.FUNC(iters); \
} \
} \
BENCHMARK_RANGE(BM_##FUNC##_##D1##x##D2##x##D3##_##THREADS##T, 10, 5000);
BM_FuncWithInputDimsCPU(contraction, N, N, N, 1);
BM_FuncWithInputDimsCPU(contraction, N, N, N, 4);
BM_FuncWithInputDimsCPU(contraction, N, N, N, 8);
BM_FuncWithInputDimsCPU(contraction, N, N, N, 12);
BM_FuncWithInputDimsCPU(contraction, N, N, N, 16);
BM_FuncWithInputDimsCPU(contraction, 64, N, N, 1);
BM_FuncWithInputDimsCPU(contraction, 64, N, N, 4);
BM_FuncWithInputDimsCPU(contraction, 64, N, N, 8);
BM_FuncWithInputDimsCPU(contraction, 64, N, N, 12);
BM_FuncWithInputDimsCPU(contraction, 64, N, N, 16);
BM_FuncWithInputDimsCPU(contraction, N, 64, N, 1);
BM_FuncWithInputDimsCPU(contraction, N, 64, N, 4);
BM_FuncWithInputDimsCPU(contraction, N, 64, N, 8);
BM_FuncWithInputDimsCPU(contraction, N, 64, N, 12);
BM_FuncWithInputDimsCPU(contraction, N, 64, N, 16);
BM_FuncWithInputDimsCPU(contraction, N, N, 64, 1);
BM_FuncWithInputDimsCPU(contraction, N, N, 64, 4);
BM_FuncWithInputDimsCPU(contraction, N, N, 64, 8);
BM_FuncWithInputDimsCPU(contraction, N, N, 64, 12);
BM_FuncWithInputDimsCPU(contraction, N, N, 64, 16);
BM_FuncWithInputDimsCPU(contraction, 1, N, N, 1);
BM_FuncWithInputDimsCPU(contraction, 1, N, N, 4);
BM_FuncWithInputDimsCPU(contraction, 1, N, N, 8);
BM_FuncWithInputDimsCPU(contraction, 1, N, N, 12);
BM_FuncWithInputDimsCPU(contraction, 1, N, N, 16);
BM_FuncWithInputDimsCPU(contraction, N, N, 1, 1);
BM_FuncWithInputDimsCPU(contraction, N, N, 1, 4);
BM_FuncWithInputDimsCPU(contraction, N, N, 1, 8);
BM_FuncWithInputDimsCPU(contraction, N, N, 1, 12);
BM_FuncWithInputDimsCPU(contraction, N, N, 1, 16);
// Convolutions
#define BM_FuncWithKernelDimsCPU(FUNC, DIM1, DIM2, THREADS) \
static void BM_##FUNC##_##DIM1##x##DIM2##_##THREADS##T(int iters, int N) { \
StopBenchmarkTiming(); \
CREATE_THREAD_POOL(THREADS); \
BenchmarkSuite<Eigen::ThreadPoolDevice, float> suite(device, N); \
suite.FUNC(iters, DIM1, DIM2); \
} \
BENCHMARK_RANGE(BM_##FUNC##_##DIM1##x##DIM2##_##THREADS##T, 128, 5000);
BM_FuncWithKernelDimsCPU(convolution, 7, 1, 4);
BM_FuncWithKernelDimsCPU(convolution, 7, 1, 8);
BM_FuncWithKernelDimsCPU(convolution, 7, 1, 12);
BM_FuncWithKernelDimsCPU(convolution, 1, 7, 4);
BM_FuncWithKernelDimsCPU(convolution, 1, 7, 8);
BM_FuncWithKernelDimsCPU(convolution, 1, 7, 12);
BM_FuncWithKernelDimsCPU(convolution, 7, 4, 4);
BM_FuncWithKernelDimsCPU(convolution, 7, 4, 8);
BM_FuncWithKernelDimsCPU(convolution, 7, 4, 12);
BM_FuncWithKernelDimsCPU(convolution, 4, 7, 4);
BM_FuncWithKernelDimsCPU(convolution, 4, 7, 8);
BM_FuncWithKernelDimsCPU(convolution, 4, 7, 12);
BM_FuncWithKernelDimsCPU(convolution, 7, 64, 4);
BM_FuncWithKernelDimsCPU(convolution, 7, 64, 8);
BM_FuncWithKernelDimsCPU(convolution, 7, 64, 12);
BM_FuncWithKernelDimsCPU(convolution, 64, 7, 4);
BM_FuncWithKernelDimsCPU(convolution, 64, 7, 8);
BM_FuncWithKernelDimsCPU(convolution, 64, 7, 12);
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/tensors/tensor_benchmarks.h | .h | 16,193 | 479 | #ifndef THIRD_PARTY_EIGEN3_TENSOR_BENCHMARKS_H_
#define THIRD_PARTY_EIGEN3_TENSOR_BENCHMARKS_H_
typedef int TensorIndex;
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int
#include "unsupported/Eigen/CXX11/Tensor"
#include "benchmark.h"
#define BENCHMARK_RANGE(bench, lo, hi) \
BENCHMARK(bench)->Range(lo, hi)
using Eigen::Tensor;
using Eigen::TensorMap;
// TODO(bsteiner): also templatize on the input type since we have users
// for int8 as well as floats.
template <typename Device, typename T> class BenchmarkSuite {
public:
BenchmarkSuite(const Device& device, size_t m, size_t k, size_t n)
: m_(m), k_(k), n_(n), device_(device) {
initialize();
}
BenchmarkSuite(const Device& device, size_t m)
: m_(m), k_(m), n_(m), device_(device) {
initialize();
}
~BenchmarkSuite() {
device_.deallocate(a_);
device_.deallocate(b_);
device_.deallocate(c_);
}
void memcpy(int num_iters) {
eigen_assert(m_ == k_ && k_ == n_);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
device_.memcpy(c_, a_, m_ * m_ * sizeof(T));
}
// Record the number of values copied per second
finalizeBenchmark(static_cast<int64_t>(m_) * m_ * num_iters);
}
void typeCasting(int num_iters) {
eigen_assert(m_ == n_);
Eigen::array<TensorIndex, 2> sizes;
if (sizeof(T) >= sizeof(int)) {
sizes[0] = m_;
sizes[1] = k_;
} else {
sizes[0] = m_ * sizeof(T) / sizeof(int);
sizes[1] = k_ * sizeof(T) / sizeof(int);
}
const TensorMap<Tensor<int, 2, 0, TensorIndex>, Eigen::Aligned> A((int*)a_, sizes);
TensorMap<Tensor<T, 2, 0, TensorIndex>, Eigen::Aligned> B(b_, sizes);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
B.device(device_) = A.template cast<T>();
}
// Record the number of values copied per second
finalizeBenchmark(static_cast<int64_t>(m_) * k_ * num_iters);
}
void random(int num_iters) {
eigen_assert(m_ == k_ && k_ == n_);
Eigen::array<TensorIndex, 2> sizes;
sizes[0] = m_;
sizes[1] = m_;
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, sizes);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = C.random();
}
// Record the number of random numbers generated per second
finalizeBenchmark(static_cast<int64_t>(m_) * m_ * num_iters);
}
void slicing(int num_iters) {
eigen_assert(m_ == k_ && k_ == n_);
Eigen::array<TensorIndex, 2> sizes;
sizes[0] = m_;
sizes[1] = m_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, sizes);
const TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, sizes);
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, sizes);
const Eigen::DSizes<TensorIndex, 2> quarter_sizes(m_/2, m_/2);
const Eigen::DSizes<TensorIndex, 2> first_quadrant(0, 0);
const Eigen::DSizes<TensorIndex, 2> second_quadrant(0, m_/2);
const Eigen::DSizes<TensorIndex, 2> third_quadrant(m_/2, 0);
const Eigen::DSizes<TensorIndex, 2> fourth_quadrant(m_/2, m_/2);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.slice(first_quadrant, quarter_sizes).device(device_) =
A.slice(first_quadrant, quarter_sizes);
C.slice(second_quadrant, quarter_sizes).device(device_) =
B.slice(second_quadrant, quarter_sizes);
C.slice(third_quadrant, quarter_sizes).device(device_) =
A.slice(third_quadrant, quarter_sizes);
C.slice(fourth_quadrant, quarter_sizes).device(device_) =
B.slice(fourth_quadrant, quarter_sizes);
}
// Record the number of values copied from the rhs slice to the lhs slice
// each second
finalizeBenchmark(static_cast<int64_t>(m_) * m_ * num_iters);
}
void rowChip(int num_iters) {
Eigen::array<TensorIndex, 2> input_size;
input_size[0] = k_;
input_size[1] = n_;
const TensorMap<Tensor<T, 2, 0, TensorIndex>, Eigen::Aligned> B(b_, input_size);
Eigen::array<TensorIndex, 1> output_size;
output_size[0] = n_;
TensorMap<Tensor<T, 1, 0, TensorIndex>, Eigen::Aligned> C(c_, output_size);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = B.chip(iter % k_, 0);
}
// Record the number of values copied from the rhs chip to the lhs.
finalizeBenchmark(static_cast<int64_t>(n_) * num_iters);
}
void colChip(int num_iters) {
Eigen::array<TensorIndex, 2> input_size;
input_size[0] = k_;
input_size[1] = n_;
const TensorMap<Tensor<T, 2, 0, TensorIndex>, Eigen::Aligned> B(b_, input_size);
Eigen::array<TensorIndex, 1> output_size;
output_size[0] = n_;
TensorMap<Tensor<T, 1, 0, TensorIndex>, Eigen::Aligned> C(c_, output_size);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = B.chip(iter % n_, 1);
}
// Record the number of values copied from the rhs chip to the lhs.
finalizeBenchmark(static_cast<int64_t>(n_) * num_iters);
}
void shuffling(int num_iters) {
eigen_assert(m_ == n_);
Eigen::array<TensorIndex, 2> size_a;
size_a[0] = m_;
size_a[1] = k_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, size_a);
Eigen::array<TensorIndex, 2> size_b;
size_b[0] = k_;
size_b[1] = m_;
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
Eigen::array<int, 2> shuffle;
shuffle[0] = 1;
shuffle[1] = 0;
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
B.device(device_) = A.shuffle(shuffle);
}
// Record the number of values shuffled from A and copied to B each second
finalizeBenchmark(static_cast<int64_t>(m_) * k_ * num_iters);
}
void padding(int num_iters) {
eigen_assert(m_ == k_);
Eigen::array<TensorIndex, 2> size_a;
size_a[0] = m_;
size_a[1] = k_-3;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, size_a);
Eigen::array<TensorIndex, 2> size_b;
size_b[0] = k_;
size_b[1] = m_;
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
#if defined(EIGEN_HAS_INDEX_LIST)
Eigen::IndexPairList<Eigen::type2indexpair<0, 0>,
Eigen::type2indexpair<2, 1> > paddings;
#else
Eigen::array<Eigen::IndexPair<TensorIndex>, 2> paddings;
paddings[0] = Eigen::IndexPair<TensorIndex>(0, 0);
paddings[1] = Eigen::IndexPair<TensorIndex>(2, 1);
#endif
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
B.device(device_) = A.pad(paddings);
}
// Record the number of values copied from the padded tensor A each second
finalizeBenchmark(static_cast<int64_t>(m_) * k_ * num_iters);
}
void striding(int num_iters) {
eigen_assert(m_ == k_);
Eigen::array<TensorIndex, 2> size_a;
size_a[0] = m_;
size_a[1] = k_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, size_a);
Eigen::array<TensorIndex, 2> size_b;
size_b[0] = m_;
size_b[1] = k_/2;
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
#ifndef EIGEN_HAS_INDEX_LIST
Eigen::array<TensorIndex, 2> strides;
strides[0] = 1;
strides[1] = 2;
#else
// Take advantage of cxx11 to give the compiler information it can use to
// optimize the code.
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<2> > strides;
#endif
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
B.device(device_) = A.stride(strides);
}
// Record the number of values copied from the padded tensor A each second
finalizeBenchmark(static_cast<int64_t>(m_) * k_ * num_iters);
}
void broadcasting(int num_iters) {
Eigen::array<TensorIndex, 2> size_a;
size_a[0] = m_;
size_a[1] = 1;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, size_a);
Eigen::array<TensorIndex, 2> size_c;
size_c[0] = m_;
size_c[1] = n_;
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, size_c);
#ifndef EIGEN_HAS_INDEX_LIST
Eigen::array<int, 2> broadcast;
broadcast[0] = 1;
broadcast[1] = n_;
#else
// Take advantage of cxx11 to give the compiler information it can use to
// optimize the code.
Eigen::IndexList<Eigen::type2index<1>, int> broadcast;
broadcast.set(1, n_);
#endif
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = A.broadcast(broadcast);
}
// Record the number of values broadcasted from A and copied to C each second
finalizeBenchmark(static_cast<int64_t>(m_) * n_ * num_iters);
}
void coeffWiseOp(int num_iters) {
eigen_assert(m_ == k_ && k_ == n_);
Eigen::array<TensorIndex, 2> sizes;
sizes[0] = m_;
sizes[1] = m_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, sizes);
const TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, sizes);
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, sizes);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = A * A.constant(static_cast<T>(3.14)) + B * B.constant(static_cast<T>(2.7));
}
// Record the number of FLOP executed per second (2 multiplications and
// 1 addition per value)
finalizeBenchmark(static_cast<int64_t>(3) * m_ * m_ * num_iters);
}
void algebraicFunc(int num_iters) {
eigen_assert(m_ == k_ && k_ == n_);
Eigen::array<TensorIndex, 2> sizes;
sizes[0] = m_;
sizes[1] = m_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, sizes);
const TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, sizes);
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, sizes);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = A.rsqrt() + B.sqrt() * B.square();
}
// Record the number of FLOP executed per second (assuming one operation
// per value)
finalizeBenchmark(static_cast<int64_t>(m_) * m_ * num_iters);
}
void transcendentalFunc(int num_iters) {
eigen_assert(m_ == k_ && k_ == n_);
Eigen::array<TensorIndex, 2> sizes;
sizes[0] = m_;
sizes[1] = m_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, sizes);
const TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, sizes);
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, sizes);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = A.exp() + B.log();
}
// Record the number of FLOP executed per second (assuming one operation
// per value)
finalizeBenchmark(static_cast<int64_t>(m_) * m_ * num_iters);
}
// Row reduction
void rowReduction(int num_iters) {
Eigen::array<TensorIndex, 2> input_size;
input_size[0] = k_;
input_size[1] = n_;
const TensorMap<Tensor<T, 2, 0, TensorIndex>, Eigen::Aligned> B(b_, input_size);
Eigen::array<TensorIndex, 1> output_size;
output_size[0] = n_;
TensorMap<Tensor<T, 1, 0, TensorIndex>, Eigen::Aligned> C(c_, output_size);
#ifndef EIGEN_HAS_INDEX_LIST
Eigen::array<TensorIndex, 1> sum_along_dim;
sum_along_dim[0] = 0;
#else
// Take advantage of cxx11 to give the compiler information it can use to
// optimize the code.
Eigen::IndexList<Eigen::type2index<0>> sum_along_dim;
#endif
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = B.sum(sum_along_dim);
}
// Record the number of FLOP executed per second (assuming one operation
// per value)
finalizeBenchmark(static_cast<int64_t>(k_) * n_ * num_iters);
}
// Column reduction
void colReduction(int num_iters) {
Eigen::array<TensorIndex, 2> input_size;
input_size[0] = k_;
input_size[1] = n_;
const TensorMap<Tensor<T, 2, 0, TensorIndex>, Eigen::Aligned> B(
b_, input_size);
Eigen::array<TensorIndex, 1> output_size;
output_size[0] = k_;
TensorMap<Tensor<T, 1, 0, TensorIndex>, Eigen::Aligned> C(
c_, output_size);
#ifndef EIGEN_HAS_INDEX_LIST
Eigen::array<TensorIndex, 1> sum_along_dim;
sum_along_dim[0] = 1;
#else
// Take advantage of cxx11 to give the compiler information it can use to
// optimize the code.
Eigen::IndexList<Eigen::type2index<1>> sum_along_dim;
#endif
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = B.sum(sum_along_dim);
}
// Record the number of FLOP executed per second (assuming one operation
// per value)
finalizeBenchmark(static_cast<int64_t>(k_) * n_ * num_iters);
}
// Full reduction
void fullReduction(int num_iters) {
Eigen::array<TensorIndex, 2> input_size;
input_size[0] = k_;
input_size[1] = n_;
const TensorMap<Tensor<T, 2, 0, TensorIndex>, Eigen::Aligned> B(
b_, input_size);
Eigen::array<TensorIndex, 0> output_size;
TensorMap<Tensor<T, 0, 0, TensorIndex>, Eigen::Aligned> C(
c_, output_size);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = B.sum();
}
// Record the number of FLOP executed per second (assuming one operation
// per value)
finalizeBenchmark(static_cast<int64_t>(k_) * n_ * num_iters);
}
// do a contraction which is equivalent to a matrix multiplication
void contraction(int num_iters) {
Eigen::array<TensorIndex, 2> sizeA;
sizeA[0] = m_;
sizeA[1] = k_;
Eigen::array<TensorIndex, 2> sizeB;
sizeB[0] = k_;
sizeB[1] = n_;
Eigen::array<TensorIndex, 2> sizeC;
sizeC[0] = m_;
sizeC[1] = n_;
const TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, sizeA);
const TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, sizeB);
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, sizeC);
typedef typename Tensor<T, 2>::DimensionPair DimPair;
Eigen::array<DimPair, 1> dims;
dims[0] = DimPair(1, 0);
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = A.contract(B, dims);
}
// Record the number of FLOP executed per second (size_ multiplications and
// additions for each value in the resulting tensor)
finalizeBenchmark(static_cast<int64_t>(2) * m_ * n_ * k_ * num_iters);
}
void convolution(int num_iters, int kernel_x, int kernel_y) {
Eigen::array<TensorIndex, 2> input_sizes;
input_sizes[0] = m_;
input_sizes[1] = n_;
TensorMap<Tensor<T, 2>, Eigen::Aligned> A(a_, input_sizes);
Eigen::array<TensorIndex, 2> kernel_sizes;
kernel_sizes[0] = kernel_x;
kernel_sizes[1] = kernel_y;
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, kernel_sizes);
Eigen::array<TensorIndex, 2> result_sizes;
result_sizes[0] = m_ - kernel_x + 1;
result_sizes[1] = n_ - kernel_y + 1;
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, result_sizes);
Eigen::array<TensorIndex, 2> dims;
dims[0] = 0;
dims[1] = 1;
StartBenchmarkTiming();
for (int iter = 0; iter < num_iters; ++iter) {
C.device(device_) = A.convolve(B, dims);
}
// Record the number of FLOP executed per second (kernel_size
// multiplications and additions for each value in the resulting tensor)
finalizeBenchmark(static_cast<int64_t>(2) *
(m_ - kernel_x + 1) * (n_ - kernel_y + 1) * kernel_x * kernel_y * num_iters);
}
private:
void initialize() {
a_ = (T *) device_.allocate(m_ * k_ * sizeof(T));
b_ = (T *) device_.allocate(k_ * n_ * sizeof(T));
c_ = (T *) device_.allocate(m_ * n_ * sizeof(T));
// Initialize the content of the memory pools to prevent asan from
// complaining.
device_.memset(a_, 12, m_ * k_ * sizeof(T));
device_.memset(b_, 23, k_ * n_ * sizeof(T));
device_.memset(c_, 31, m_ * n_ * sizeof(T));
//BenchmarkUseRealTime();
}
inline void finalizeBenchmark(int64_t num_items) {
#if defined(EIGEN_USE_GPU) && defined(__CUDACC__)
if (Eigen::internal::is_same<Device, Eigen::GpuDevice>::value) {
device_.synchronize();
}
#endif
StopBenchmarkTiming();
SetBenchmarkFlopsProcessed(num_items);
}
TensorIndex m_;
TensorIndex k_;
TensorIndex n_;
T* a_;
T* b_;
T* c_;
Device device_;
};
#endif // THIRD_PARTY_EIGEN3_TENSOR_BENCHMARKS_H_
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/tensors/benchmark.h | .h | 1,585 | 50 | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stddef.h>
#include <stdint.h>
#include <vector>
namespace testing {
class Benchmark {
public:
Benchmark(const char* name, void (*fn)(int)) {
Register(name, fn, NULL);
}
Benchmark(const char* name, void (*fn_range)(int, int)) {
Register(name, NULL, fn_range);
}
Benchmark* Arg(int x);
Benchmark* Range(int lo, int hi);
const char* Name();
bool ShouldRun(int argc, char* argv[]);
void Run();
private:
const char* name_;
void (*fn_)(int);
void (*fn_range_)(int, int);
std::vector<int> args_;
void Register(const char* name, void (*fn)(int), void (*fn_range)(int, int));
void RunRepeatedlyWithArg(int iterations, int arg);
void RunWithArg(int arg);
};
} // namespace testing
void SetBenchmarkFlopsProcessed(int64_t);
void StopBenchmarkTiming();
void StartBenchmarkTiming();
#define BENCHMARK(f) \
static ::testing::Benchmark* _benchmark_##f __attribute__((unused)) = \
(new ::testing::Benchmark(#f, f))
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/tensors/tensor_benchmarks_sycl.cc | .cc | 1,153 | 38 | #define EIGEN_USE_SYCL
#include <SYCL/sycl.hpp>
#include <iostream>
#include "tensor_benchmarks.h"
using Eigen::array;
using Eigen::SyclDevice;
using Eigen::Tensor;
using Eigen::TensorMap;
// Simple functions
template <typename device_selector>
cl::sycl::queue sycl_queue() {
return cl::sycl::queue(device_selector(), [=](cl::sycl::exception_list l) {
for (const auto& e : l) {
try {
std::rethrow_exception(e);
} catch (cl::sycl::exception e) {
std::cout << e.what() << std::endl;
}
}
});
}
#define BM_FuncGPU(FUNC) \
static void BM_##FUNC(int iters, int N) { \
StopBenchmarkTiming(); \
cl::sycl::queue q = sycl_queue<cl::sycl::gpu_selector>(); \
Eigen::SyclDevice device(q); \
BenchmarkSuite<Eigen::SyclDevice, float> suite(device, N); \
suite.FUNC(iters); \
} \
BENCHMARK_RANGE(BM_##FUNC, 10, 5000);
BM_FuncGPU(broadcasting);
BM_FuncGPU(coeffWiseOp);
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/spbench/test_sparseLU.cpp | .cpp | 2,830 | 93 | // Small bench routine for Eigen available in Eigen
// (C) Desire NUENTSA WAKAM, INRIA
#include <iostream>
#include <fstream>
#include <iomanip>
#include <unsupported/Eigen/SparseExtra>
#include <Eigen/SparseLU>
#include <bench/BenchTimer.h>
#ifdef EIGEN_METIS_SUPPORT
#include <Eigen/MetisSupport>
#endif
using namespace std;
using namespace Eigen;
int main(int argc, char **args)
{
// typedef complex<double> scalar;
typedef double scalar;
SparseMatrix<scalar, ColMajor> A;
typedef SparseMatrix<scalar, ColMajor>::Index Index;
typedef Matrix<scalar, Dynamic, Dynamic> DenseMatrix;
typedef Matrix<scalar, Dynamic, 1> DenseRhs;
Matrix<scalar, Dynamic, 1> b, x, tmp;
// SparseLU<SparseMatrix<scalar, ColMajor>, AMDOrdering<int> > solver;
// #ifdef EIGEN_METIS_SUPPORT
// SparseLU<SparseMatrix<scalar, ColMajor>, MetisOrdering<int> > solver;
// std::cout<< "ORDERING : METIS\n";
// #else
SparseLU<SparseMatrix<scalar, ColMajor>, COLAMDOrdering<int> > solver;
std::cout<< "ORDERING : COLAMD\n";
// #endif
ifstream matrix_file;
string line;
int n;
BenchTimer timer;
// Set parameters
/* Fill the matrix with sparse matrix stored in Matrix-Market coordinate column-oriented format */
if (argc < 2) assert(false && "please, give the matrix market file ");
loadMarket(A, args[1]);
cout << "End charging matrix " << endl;
bool iscomplex=false, isvector=false;
int sym;
getMarketHeader(args[1], sym, iscomplex, isvector);
// if (iscomplex) { cout<< " Not for complex matrices \n"; return -1; }
if (isvector) { cout << "The provided file is not a matrix file\n"; return -1;}
if (sym != 0) { // symmetric matrices, only the lower part is stored
SparseMatrix<scalar, ColMajor> temp;
temp = A;
A = temp.selfadjointView<Lower>();
}
n = A.cols();
/* Fill the right hand side */
if (argc > 2)
loadMarketVector(b, args[2]);
else
{
b.resize(n);
tmp.resize(n);
// tmp.setRandom();
for (int i = 0; i < n; i++) tmp(i) = i;
b = A * tmp ;
}
/* Compute the factorization */
// solver.isSymmetric(true);
timer.start();
// solver.compute(A);
solver.analyzePattern(A);
timer.stop();
cout << "Time to analyze " << timer.value() << std::endl;
timer.reset();
timer.start();
solver.factorize(A);
timer.stop();
cout << "Factorize Time " << timer.value() << std::endl;
timer.reset();
timer.start();
x = solver.solve(b);
timer.stop();
cout << "solve time " << timer.value() << std::endl;
/* Check the accuracy */
Matrix<scalar, Dynamic, 1> tmp2 = b - A*x;
scalar tempNorm = tmp2.norm()/b.norm();
cout << "Relative norm of the computed solution : " << tempNorm <<"\n";
cout << "Number of nonzeros in the factor : " << solver.nnzL() + solver.nnzU() << std::endl;
return 0;
} | C++ |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/spbench/sp_solver.cpp | .cpp | 3,974 | 125 | // Small bench routine for Eigen available in Eigen
// (C) Desire NUENTSA WAKAM, INRIA
#include <iostream>
#include <fstream>
#include <iomanip>
#include <Eigen/Jacobi>
#include <Eigen/Householder>
#include <Eigen/IterativeLinearSolvers>
#include <Eigen/LU>
#include <unsupported/Eigen/SparseExtra>
//#include <Eigen/SparseLU>
#include <Eigen/SuperLUSupport>
// #include <unsupported/Eigen/src/IterativeSolvers/Scaling.h>
#include <bench/BenchTimer.h>
#include <unsupported/Eigen/IterativeSolvers>
using namespace std;
using namespace Eigen;
int main(int argc, char **args)
{
SparseMatrix<double, ColMajor> A;
typedef SparseMatrix<double, ColMajor>::Index Index;
typedef Matrix<double, Dynamic, Dynamic> DenseMatrix;
typedef Matrix<double, Dynamic, 1> DenseRhs;
VectorXd b, x, tmp;
BenchTimer timer,totaltime;
//SparseLU<SparseMatrix<double, ColMajor> > solver;
// SuperLU<SparseMatrix<double, ColMajor> > solver;
ConjugateGradient<SparseMatrix<double, ColMajor>, Lower,IncompleteCholesky<double,Lower> > solver;
ifstream matrix_file;
string line;
int n;
// Set parameters
// solver.iparm(IPARM_THREAD_NBR) = 4;
/* Fill the matrix with sparse matrix stored in Matrix-Market coordinate column-oriented format */
if (argc < 2) assert(false && "please, give the matrix market file ");
timer.start();
totaltime.start();
loadMarket(A, args[1]);
cout << "End charging matrix " << endl;
bool iscomplex=false, isvector=false;
int sym;
getMarketHeader(args[1], sym, iscomplex, isvector);
if (iscomplex) { cout<< " Not for complex matrices \n"; return -1; }
if (isvector) { cout << "The provided file is not a matrix file\n"; return -1;}
if (sym != 0) { // symmetric matrices, only the lower part is stored
SparseMatrix<double, ColMajor> temp;
temp = A;
A = temp.selfadjointView<Lower>();
}
timer.stop();
n = A.cols();
// ====== TESTS FOR SPARSE TUTORIAL ======
// cout<< "OuterSize " << A.outerSize() << " inner " << A.innerSize() << endl;
// SparseMatrix<double, RowMajor> mat1(A);
// SparseMatrix<double, RowMajor> mat2;
// cout << " norm of A " << mat1.norm() << endl; ;
// PermutationMatrix<Dynamic, Dynamic, int> perm(n);
// perm.resize(n,1);
// perm.indices().setLinSpaced(n, 0, n-1);
// mat2 = perm * mat1;
// mat.subrows();
// mat2.resize(n,n);
// mat2.reserve(10);
// mat2.setConstant();
// std::cout<< "NORM " << mat1.squaredNorm()<< endl;
cout<< "Time to load the matrix " << timer.value() <<endl;
/* Fill the right hand side */
// solver.set_restart(374);
if (argc > 2)
loadMarketVector(b, args[2]);
else
{
b.resize(n);
tmp.resize(n);
// tmp.setRandom();
for (int i = 0; i < n; i++) tmp(i) = i;
b = A * tmp ;
}
// Scaling<SparseMatrix<double> > scal;
// scal.computeRef(A);
// b = scal.LeftScaling().cwiseProduct(b);
/* Compute the factorization */
cout<< "Starting the factorization "<< endl;
timer.reset();
timer.start();
cout<< "Size of Input Matrix "<< b.size()<<"\n\n";
cout<< "Rows and columns "<< A.rows() <<" " <<A.cols() <<"\n";
solver.compute(A);
// solver.analyzePattern(A);
// solver.factorize(A);
if (solver.info() != Success) {
std::cout<< "The solver failed \n";
return -1;
}
timer.stop();
float time_comp = timer.value();
cout <<" Compute Time " << time_comp<< endl;
timer.reset();
timer.start();
x = solver.solve(b);
// x = scal.RightScaling().cwiseProduct(x);
timer.stop();
float time_solve = timer.value();
cout<< " Time to solve " << time_solve << endl;
/* Check the accuracy */
VectorXd tmp2 = b - A*x;
double tempNorm = tmp2.norm()/b.norm();
cout << "Relative norm of the computed solution : " << tempNorm <<"\n";
// cout << "Iterations : " << solver.iterations() << "\n";
totaltime.stop();
cout << "Total time " << totaltime.value() << "\n";
// std::cout<<x.transpose()<<"\n";
return 0;
} | C++ |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/spbench/spbenchstyle.h | .h | 3,825 | 96 | // This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef SPBENCHSTYLE_H
#define SPBENCHSTYLE_H
void printBenchStyle(std::ofstream& out)
{
out << "<xsl:stylesheet id='stylesheet' version='1.0' \
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >\n \
<xsl:template match='xsl:stylesheet' />\n \
<xsl:template match='/'> <!-- Root of the document -->\n \
<html>\n \
<head> \n \
<style type='text/css'> \n \
td { white-space: nowrap;}\n \
</style>\n \
</head>\n \
<body>";
out<<"<table border='1' width='100%' height='100%'>\n \
<TR> <!-- Write the table header -->\n \
<TH>Matrix</TH> <TH>N</TH> <TH> NNZ</TH> <TH> Sym</TH> <TH> SPD</TH> <TH> </TH>\n \
<xsl:for-each select='BENCH/AVAILSOLVER/SOLVER'>\n \
<xsl:sort select='@ID' data-type='number'/>\n \
<TH>\n \
<xsl:value-of select='TYPE' />\n \
<xsl:text></xsl:text>\n \
<xsl:value-of select='PACKAGE' />\n \
<xsl:text></xsl:text>\n \
</TH>\n \
</xsl:for-each>\n \
</TR>";
out<<" <xsl:for-each select='BENCH/LINEARSYSTEM'>\n \
<TR> <!-- print statistics for one linear system-->\n \
<TH rowspan='4'> <xsl:value-of select='MATRIX/NAME' /> </TH>\n \
<TD rowspan='4'> <xsl:value-of select='MATRIX/SIZE' /> </TD>\n \
<TD rowspan='4'> <xsl:value-of select='MATRIX/ENTRIES' /> </TD>\n \
<TD rowspan='4'> <xsl:value-of select='MATRIX/SYMMETRY' /> </TD>\n \
<TD rowspan='4'> <xsl:value-of select='MATRIX/POSDEF' /> </TD>\n \
<TH> Compute Time </TH>\n \
<xsl:for-each select='SOLVER_STAT'>\n \
<xsl:sort select='@ID' data-type='number'/>\n \
<TD> <xsl:value-of select='TIME/COMPUTE' /> </TD>\n \
</xsl:for-each>\n \
</TR>";
out<<" <TR>\n \
<TH> Solve Time </TH>\n \
<xsl:for-each select='SOLVER_STAT'>\n \
<xsl:sort select='@ID' data-type='number'/>\n \
<TD> <xsl:value-of select='TIME/SOLVE' /> </TD>\n \
</xsl:for-each>\n \
</TR>\n \
<TR>\n \
<TH> Total Time </TH>\n \
<xsl:for-each select='SOLVER_STAT'>\n \
<xsl:sort select='@ID' data-type='number'/>\n \
<xsl:choose>\n \
<xsl:when test='@ID=../BEST_SOLVER/@ID'>\n \
<TD style='background-color:red'> <xsl:value-of select='TIME/TOTAL' /> </TD>\n \
</xsl:when>\n \
<xsl:otherwise>\n \
<TD> <xsl:value-of select='TIME/TOTAL' /></TD>\n \
</xsl:otherwise>\n \
</xsl:choose>\n \
</xsl:for-each>\n \
</TR>";
out<<" <TR>\n \
<TH> Error </TH>\n \
<xsl:for-each select='SOLVER_STAT'>\n \
<xsl:sort select='@ID' data-type='number'/>\n \
<TD> <xsl:value-of select='ERROR' />\n \
<xsl:if test='ITER'>\n \
<xsl:text>(</xsl:text>\n \
<xsl:value-of select='ITER' />\n \
<xsl:text>)</xsl:text>\n \
</xsl:if> </TD>\n \
</xsl:for-each>\n \
</TR>\n \
</xsl:for-each>\n \
</table>\n \
</body>\n \
</html>\n \
</xsl:template>\n \
</xsl:stylesheet>\n\n";
}
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/spbench/spbenchsolver.h | .h | 17,717 | 555 | // This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <iostream>
#include <fstream>
#include <Eigen/SparseCore>
#include <bench/BenchTimer.h>
#include <cstdlib>
#include <string>
#include <Eigen/Cholesky>
#include <Eigen/Jacobi>
#include <Eigen/Householder>
#include <Eigen/IterativeLinearSolvers>
#include <unsupported/Eigen/IterativeSolvers>
#include <Eigen/LU>
#include <unsupported/Eigen/SparseExtra>
#include <Eigen/SparseLU>
#include "spbenchstyle.h"
#ifdef EIGEN_METIS_SUPPORT
#include <Eigen/MetisSupport>
#endif
#ifdef EIGEN_CHOLMOD_SUPPORT
#include <Eigen/CholmodSupport>
#endif
#ifdef EIGEN_UMFPACK_SUPPORT
#include <Eigen/UmfPackSupport>
#endif
#ifdef EIGEN_PARDISO_SUPPORT
#include <Eigen/PardisoSupport>
#endif
#ifdef EIGEN_SUPERLU_SUPPORT
#include <Eigen/SuperLUSupport>
#endif
#ifdef EIGEN_PASTIX_SUPPORT
#include <Eigen/PaStiXSupport>
#endif
// CONSTANTS
#define EIGEN_UMFPACK 10
#define EIGEN_SUPERLU 20
#define EIGEN_PASTIX 30
#define EIGEN_PARDISO 40
#define EIGEN_SPARSELU_COLAMD 50
#define EIGEN_SPARSELU_METIS 51
#define EIGEN_BICGSTAB 60
#define EIGEN_BICGSTAB_ILUT 61
#define EIGEN_GMRES 70
#define EIGEN_GMRES_ILUT 71
#define EIGEN_SIMPLICIAL_LDLT 80
#define EIGEN_CHOLMOD_LDLT 90
#define EIGEN_PASTIX_LDLT 100
#define EIGEN_PARDISO_LDLT 110
#define EIGEN_SIMPLICIAL_LLT 120
#define EIGEN_CHOLMOD_SUPERNODAL_LLT 130
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT 140
#define EIGEN_PASTIX_LLT 150
#define EIGEN_PARDISO_LLT 160
#define EIGEN_CG 170
#define EIGEN_CG_PRECOND 180
using namespace Eigen;
using namespace std;
// Global variables for input parameters
int MaximumIters; // Maximum number of iterations
double RelErr; // Relative error of the computed solution
double best_time_val; // Current best time overall solvers
int best_time_id; // id of the best solver for the current system
template<typename T> inline typename NumTraits<T>::Real test_precision() { return NumTraits<T>::dummy_precision(); }
template<> inline float test_precision<float>() { return 1e-3f; }
template<> inline double test_precision<double>() { return 1e-6; }
template<> inline float test_precision<std::complex<float> >() { return test_precision<float>(); }
template<> inline double test_precision<std::complex<double> >() { return test_precision<double>(); }
void printStatheader(std::ofstream& out)
{
// Print XML header
// NOTE It would have been much easier to write these XML documents using external libraries like tinyXML or Xerces-C++.
out << "<?xml version='1.0' encoding='UTF-8'?> \n";
out << "<?xml-stylesheet type='text/xsl' href='#stylesheet' ?> \n";
out << "<!DOCTYPE BENCH [\n<!ATTLIST xsl:stylesheet\n id\t ID #REQUIRED>\n]>";
out << "\n\n<!-- Generated by the Eigen library -->\n";
out << "\n<BENCH> \n" ; //root XML element
// Print the xsl style section
printBenchStyle(out);
// List all available solvers
out << " <AVAILSOLVER> \n";
#ifdef EIGEN_UMFPACK_SUPPORT
out <<" <SOLVER ID='" << EIGEN_UMFPACK << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> UMFPACK </PACKAGE> \n";
out << " </SOLVER> \n";
#endif
#ifdef EIGEN_SUPERLU_SUPPORT
out <<" <SOLVER ID='" << EIGEN_SUPERLU << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> SUPERLU </PACKAGE> \n";
out << " </SOLVER> \n";
#endif
#ifdef EIGEN_CHOLMOD_SUPPORT
out <<" <SOLVER ID='" << EIGEN_CHOLMOD_SIMPLICIAL_LLT << "'>\n";
out << " <TYPE> LLT SP</TYPE> \n";
out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_CHOLMOD_SUPERNODAL_LLT << "'>\n";
out << " <TYPE> LLT</TYPE> \n";
out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_CHOLMOD_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
out << " </SOLVER> \n";
#endif
#ifdef EIGEN_PARDISO_SUPPORT
out <<" <SOLVER ID='" << EIGEN_PARDISO << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> PARDISO </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PARDISO_LLT << "'>\n";
out << " <TYPE> LLT </TYPE> \n";
out << " <PACKAGE> PARDISO </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PARDISO_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> PARDISO </PACKAGE> \n";
out << " </SOLVER> \n";
#endif
#ifdef EIGEN_PASTIX_SUPPORT
out <<" <SOLVER ID='" << EIGEN_PASTIX << "'>\n";
out << " <TYPE> LU </TYPE> \n";
out << " <PACKAGE> PASTIX </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PASTIX_LLT << "'>\n";
out << " <TYPE> LLT </TYPE> \n";
out << " <PACKAGE> PASTIX </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_PASTIX_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> PASTIX </PACKAGE> \n";
out << " </SOLVER> \n";
#endif
out <<" <SOLVER ID='" << EIGEN_BICGSTAB << "'>\n";
out << " <TYPE> BICGSTAB </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_BICGSTAB_ILUT << "'>\n";
out << " <TYPE> BICGSTAB_ILUT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_GMRES_ILUT << "'>\n";
out << " <TYPE> GMRES_ILUT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_SIMPLICIAL_LDLT << "'>\n";
out << " <TYPE> LDLT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_SIMPLICIAL_LLT << "'>\n";
out << " <TYPE> LLT </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_CG << "'>\n";
out << " <TYPE> CG </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
out <<" <SOLVER ID='" << EIGEN_SPARSELU_COLAMD << "'>\n";
out << " <TYPE> LU_COLAMD </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
#ifdef EIGEN_METIS_SUPPORT
out <<" <SOLVER ID='" << EIGEN_SPARSELU_METIS << "'>\n";
out << " <TYPE> LU_METIS </TYPE> \n";
out << " <PACKAGE> EIGEN </PACKAGE> \n";
out << " </SOLVER> \n";
#endif
out << " </AVAILSOLVER> \n";
}
template<typename Solver, typename Scalar>
void call_solver(Solver &solver, const int solver_id, const typename Solver::MatrixType& A, const Matrix<Scalar, Dynamic, 1>& b, const Matrix<Scalar, Dynamic, 1>& refX,std::ofstream& statbuf)
{
double total_time;
double compute_time;
double solve_time;
double rel_error;
Matrix<Scalar, Dynamic, 1> x;
BenchTimer timer;
timer.reset();
timer.start();
solver.compute(A);
if (solver.info() != Success)
{
std::cerr << "Solver failed ... \n";
return;
}
timer.stop();
compute_time = timer.value();
statbuf << " <TIME>\n";
statbuf << " <COMPUTE> " << timer.value() << "</COMPUTE>\n";
std::cout<< "COMPUTE TIME : " << timer.value() <<std::endl;
timer.reset();
timer.start();
x = solver.solve(b);
if (solver.info() == NumericalIssue)
{
std::cerr << "Solver failed ... \n";
return;
}
timer.stop();
solve_time = timer.value();
statbuf << " <SOLVE> " << timer.value() << "</SOLVE>\n";
std::cout<< "SOLVE TIME : " << timer.value() <<std::endl;
total_time = solve_time + compute_time;
statbuf << " <TOTAL> " << total_time << "</TOTAL>\n";
std::cout<< "TOTAL TIME : " << total_time <<std::endl;
statbuf << " </TIME>\n";
// Verify the relative error
if(refX.size() != 0)
rel_error = (refX - x).norm()/refX.norm();
else
{
// Compute the relative residual norm
Matrix<Scalar, Dynamic, 1> temp;
temp = A * x;
rel_error = (b-temp).norm()/b.norm();
}
statbuf << " <ERROR> " << rel_error << "</ERROR>\n";
std::cout<< "REL. ERROR : " << rel_error << "\n\n" ;
if ( rel_error <= RelErr )
{
// check the best time if convergence
if(!best_time_val || (best_time_val > total_time))
{
best_time_val = total_time;
best_time_id = solver_id;
}
}
}
template<typename Solver, typename Scalar>
void call_directsolver(Solver& solver, const int solver_id, const typename Solver::MatrixType& A, const Matrix<Scalar, Dynamic, 1>& b, const Matrix<Scalar, Dynamic, 1>& refX, std::string& statFile)
{
std::ofstream statbuf(statFile.c_str(), std::ios::app);
statbuf << " <SOLVER_STAT ID='" << solver_id <<"'>\n";
call_solver(solver, solver_id, A, b, refX,statbuf);
statbuf << " </SOLVER_STAT>\n";
statbuf.close();
}
template<typename Solver, typename Scalar>
void call_itersolver(Solver &solver, const int solver_id, const typename Solver::MatrixType& A, const Matrix<Scalar, Dynamic, 1>& b, const Matrix<Scalar, Dynamic, 1>& refX, std::string& statFile)
{
solver.setTolerance(RelErr);
solver.setMaxIterations(MaximumIters);
std::ofstream statbuf(statFile.c_str(), std::ios::app);
statbuf << " <SOLVER_STAT ID='" << solver_id <<"'>\n";
call_solver(solver, solver_id, A, b, refX,statbuf);
statbuf << " <ITER> "<< solver.iterations() << "</ITER>\n";
statbuf << " </SOLVER_STAT>\n";
std::cout << "ITERATIONS : " << solver.iterations() <<"\n\n\n";
}
template <typename Scalar>
void SelectSolvers(const SparseMatrix<Scalar>&A, unsigned int sym, Matrix<Scalar, Dynamic, 1>& b, const Matrix<Scalar, Dynamic, 1>& refX, std::string& statFile)
{
typedef SparseMatrix<Scalar, ColMajor> SpMat;
// First, deal with Nonsymmetric and symmetric matrices
best_time_id = 0;
best_time_val = 0.0;
//UMFPACK
#ifdef EIGEN_UMFPACK_SUPPORT
{
cout << "Solving with UMFPACK LU ... \n";
UmfPackLU<SpMat> solver;
call_directsolver(solver, EIGEN_UMFPACK, A, b, refX,statFile);
}
#endif
//SuperLU
#ifdef EIGEN_SUPERLU_SUPPORT
{
cout << "\nSolving with SUPERLU ... \n";
SuperLU<SpMat> solver;
call_directsolver(solver, EIGEN_SUPERLU, A, b, refX,statFile);
}
#endif
// PaStix LU
#ifdef EIGEN_PASTIX_SUPPORT
{
cout << "\nSolving with PASTIX LU ... \n";
PastixLU<SpMat> solver;
call_directsolver(solver, EIGEN_PASTIX, A, b, refX,statFile) ;
}
#endif
//PARDISO LU
#ifdef EIGEN_PARDISO_SUPPORT
{
cout << "\nSolving with PARDISO LU ... \n";
PardisoLU<SpMat> solver;
call_directsolver(solver, EIGEN_PARDISO, A, b, refX,statFile);
}
#endif
// Eigen SparseLU METIS
cout << "\n Solving with Sparse LU AND COLAMD ... \n";
SparseLU<SpMat, COLAMDOrdering<int> > solver;
call_directsolver(solver, EIGEN_SPARSELU_COLAMD, A, b, refX, statFile);
// Eigen SparseLU METIS
#ifdef EIGEN_METIS_SUPPORT
{
cout << "\n Solving with Sparse LU AND METIS ... \n";
SparseLU<SpMat, MetisOrdering<int> > solver;
call_directsolver(solver, EIGEN_SPARSELU_METIS, A, b, refX, statFile);
}
#endif
//BiCGSTAB
{
cout << "\nSolving with BiCGSTAB ... \n";
BiCGSTAB<SpMat> solver;
call_itersolver(solver, EIGEN_BICGSTAB, A, b, refX,statFile);
}
//BiCGSTAB+ILUT
{
cout << "\nSolving with BiCGSTAB and ILUT ... \n";
BiCGSTAB<SpMat, IncompleteLUT<Scalar> > solver;
call_itersolver(solver, EIGEN_BICGSTAB_ILUT, A, b, refX,statFile);
}
//GMRES
// {
// cout << "\nSolving with GMRES ... \n";
// GMRES<SpMat> solver;
// call_itersolver(solver, EIGEN_GMRES, A, b, refX,statFile);
// }
//GMRES+ILUT
{
cout << "\nSolving with GMRES and ILUT ... \n";
GMRES<SpMat, IncompleteLUT<Scalar> > solver;
call_itersolver(solver, EIGEN_GMRES_ILUT, A, b, refX,statFile);
}
// Hermitian and not necessarily positive-definites
if (sym != NonSymmetric)
{
// Internal Cholesky
{
cout << "\nSolving with Simplicial LDLT ... \n";
SimplicialLDLT<SpMat, Lower> solver;
call_directsolver(solver, EIGEN_SIMPLICIAL_LDLT, A, b, refX,statFile);
}
// CHOLMOD
#ifdef EIGEN_CHOLMOD_SUPPORT
{
cout << "\nSolving with CHOLMOD LDLT ... \n";
CholmodDecomposition<SpMat, Lower> solver;
solver.setMode(CholmodLDLt);
call_directsolver(solver,EIGEN_CHOLMOD_LDLT, A, b, refX,statFile);
}
#endif
//PASTIX LLT
#ifdef EIGEN_PASTIX_SUPPORT
{
cout << "\nSolving with PASTIX LDLT ... \n";
PastixLDLT<SpMat, Lower> solver;
call_directsolver(solver,EIGEN_PASTIX_LDLT, A, b, refX,statFile);
}
#endif
//PARDISO LLT
#ifdef EIGEN_PARDISO_SUPPORT
{
cout << "\nSolving with PARDISO LDLT ... \n";
PardisoLDLT<SpMat, Lower> solver;
call_directsolver(solver,EIGEN_PARDISO_LDLT, A, b, refX,statFile);
}
#endif
}
// Now, symmetric POSITIVE DEFINITE matrices
if (sym == SPD)
{
//Internal Sparse Cholesky
{
cout << "\nSolving with SIMPLICIAL LLT ... \n";
SimplicialLLT<SpMat, Lower> solver;
call_directsolver(solver,EIGEN_SIMPLICIAL_LLT, A, b, refX,statFile);
}
// CHOLMOD
#ifdef EIGEN_CHOLMOD_SUPPORT
{
// CholMOD SuperNodal LLT
cout << "\nSolving with CHOLMOD LLT (Supernodal)... \n";
CholmodDecomposition<SpMat, Lower> solver;
solver.setMode(CholmodSupernodalLLt);
call_directsolver(solver,EIGEN_CHOLMOD_SUPERNODAL_LLT, A, b, refX,statFile);
// CholMod Simplicial LLT
cout << "\nSolving with CHOLMOD LLT (Simplicial) ... \n";
solver.setMode(CholmodSimplicialLLt);
call_directsolver(solver,EIGEN_CHOLMOD_SIMPLICIAL_LLT, A, b, refX,statFile);
}
#endif
//PASTIX LLT
#ifdef EIGEN_PASTIX_SUPPORT
{
cout << "\nSolving with PASTIX LLT ... \n";
PastixLLT<SpMat, Lower> solver;
call_directsolver(solver,EIGEN_PASTIX_LLT, A, b, refX,statFile);
}
#endif
//PARDISO LLT
#ifdef EIGEN_PARDISO_SUPPORT
{
cout << "\nSolving with PARDISO LLT ... \n";
PardisoLLT<SpMat, Lower> solver;
call_directsolver(solver,EIGEN_PARDISO_LLT, A, b, refX,statFile);
}
#endif
// Internal CG
{
cout << "\nSolving with CG ... \n";
ConjugateGradient<SpMat, Lower> solver;
call_itersolver(solver,EIGEN_CG, A, b, refX,statFile);
}
//CG+IdentityPreconditioner
// {
// cout << "\nSolving with CG and IdentityPreconditioner ... \n";
// ConjugateGradient<SpMat, Lower, IdentityPreconditioner> solver;
// call_itersolver(solver,EIGEN_CG_PRECOND, A, b, refX,statFile);
// }
} // End SPD matrices
}
/* Browse all the matrices available in the specified folder
* and solve the associated linear system.
* The results of each solve are printed in the standard output
* and optionally in the provided html file
*/
template <typename Scalar>
void Browse_Matrices(const string folder, bool statFileExists, std::string& statFile, int maxiters, double tol)
{
MaximumIters = maxiters; // Maximum number of iterations, global variable
RelErr = tol; //Relative residual error as stopping criterion for iterative solvers
MatrixMarketIterator<Scalar> it(folder);
for ( ; it; ++it)
{
//print the infos for this linear system
if(statFileExists)
{
std::ofstream statbuf(statFile.c_str(), std::ios::app);
statbuf << "<LINEARSYSTEM> \n";
statbuf << " <MATRIX> \n";
statbuf << " <NAME> " << it.matname() << " </NAME>\n";
statbuf << " <SIZE> " << it.matrix().rows() << " </SIZE>\n";
statbuf << " <ENTRIES> " << it.matrix().nonZeros() << "</ENTRIES>\n";
if (it.sym()!=NonSymmetric)
{
statbuf << " <SYMMETRY> Symmetric </SYMMETRY>\n" ;
if (it.sym() == SPD)
statbuf << " <POSDEF> YES </POSDEF>\n";
else
statbuf << " <POSDEF> NO </POSDEF>\n";
}
else
{
statbuf << " <SYMMETRY> NonSymmetric </SYMMETRY>\n" ;
statbuf << " <POSDEF> NO </POSDEF>\n";
}
statbuf << " </MATRIX> \n";
statbuf.close();
}
cout<< "\n\n===================================================== \n";
cout<< " ====== SOLVING WITH MATRIX " << it.matname() << " ====\n";
cout<< " =================================================== \n\n";
Matrix<Scalar, Dynamic, 1> refX;
if(it.hasrefX()) refX = it.refX();
// Call all suitable solvers for this linear system
SelectSolvers<Scalar>(it.matrix(), it.sym(), it.rhs(), refX, statFile);
if(statFileExists)
{
std::ofstream statbuf(statFile.c_str(), std::ios::app);
statbuf << " <BEST_SOLVER ID='"<< best_time_id
<< "'></BEST_SOLVER>\n";
statbuf << " </LINEARSYSTEM> \n";
statbuf.close();
}
}
}
bool get_options(int argc, char **args, string option, string* value=0)
{
int idx = 1, found=false;
while (idx<argc && !found){
if (option.compare(args[idx]) == 0){
found = true;
if(value) *value = args[idx+1];
}
idx+=2;
}
return found;
}
| Unknown |
2D | JaeHyunLee94/mpm2d | external/eigen-3.3.9/bench/spbench/spbenchsolver.cpp | .cpp | 3,302 | 88 | #include <bench/spbench/spbenchsolver.h>
void bench_printhelp()
{
cout<< " \nbenchsolver : performs a benchmark of all the solvers available in Eigen \n\n";
cout<< " MATRIX FOLDER : \n";
cout<< " The matrices for the benchmark should be collected in a folder specified with an environment variable EIGEN_MATRIXDIR \n";
cout<< " The matrices are stored using the matrix market coordinate format \n";
cout<< " The matrix and associated right-hand side (rhs) files are named respectively \n";
cout<< " as MatrixName.mtx and MatrixName_b.mtx. If the rhs does not exist, a random one is generated. \n";
cout<< " If a matrix is SPD, the matrix should be named as MatrixName_SPD.mtx \n";
cout<< " If a true solution exists, it should be named as MatrixName_x.mtx; \n" ;
cout<< " it will be used to compute the norm of the error relative to the computed solutions\n\n";
cout<< " OPTIONS : \n";
cout<< " -h or --help \n print this help and return\n\n";
cout<< " -d matrixdir \n Use matrixdir as the matrix folder instead of the one specified in the environment variable EIGEN_MATRIXDIR\n\n";
cout<< " -o outputfile.xml \n Output the statistics to a xml file \n\n";
cout<< " --eps <RelErr> Sets the relative tolerance for iterative solvers (default 1e-08) \n\n";
cout<< " --maxits <MaxIts> Sets the maximum number of iterations (default 1000) \n\n";
}
int main(int argc, char ** args)
{
bool help = ( get_options(argc, args, "-h") || get_options(argc, args, "--help") );
if(help) {
bench_printhelp();
return 0;
}
// Get the location of the test matrices
string matrix_dir;
if (!get_options(argc, args, "-d", &matrix_dir))
{
if(getenv("EIGEN_MATRIXDIR") == NULL){
std::cerr << "Please, specify the location of the matrices with -d mat_folder or the environment variable EIGEN_MATRIXDIR \n";
std::cerr << " Run with --help to see the list of all the available options \n";
return -1;
}
matrix_dir = getenv("EIGEN_MATRIXDIR");
}
std::ofstream statbuf;
string statFile ;
// Get the file to write the statistics
bool statFileExists = get_options(argc, args, "-o", &statFile);
if(statFileExists)
{
statbuf.open(statFile.c_str(), std::ios::out);
if(statbuf.good()){
statFileExists = true;
printStatheader(statbuf);
statbuf.close();
}
else
std::cerr << "Unable to open the provided file for writting... \n";
}
// Get the maximum number of iterations and the tolerance
int maxiters = 1000;
double tol = 1e-08;
string inval;
if (get_options(argc, args, "--eps", &inval))
tol = atof(inval.c_str());
if(get_options(argc, args, "--maxits", &inval))
maxiters = atoi(inval.c_str());
string current_dir;
// Test the real-arithmetics matrices
Browse_Matrices<double>(matrix_dir, statFileExists, statFile,maxiters, tol);
// Test the complex-arithmetics matrices
Browse_Matrices<std::complex<double> >(matrix_dir, statFileExists, statFile, maxiters, tol);
if(statFileExists)
{
statbuf.open(statFile.c_str(), std::ios::app);
statbuf << "</BENCH> \n";
cout << "\n Output written in " << statFile << " ...\n";
statbuf.close();
}
return 0;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_int_10_10_10_2.cpp | .cpp | 648 | 19 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2013-10-25
// Updated : 2013-10-25
// Licence : This source is under MIT licence
// File : test/gtx/associated_min_max.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/associated_min_max.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_normalize_dot.cpp | .cpp | 1,682 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_normalize_dot.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/normalize_dot.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_color_space.cpp | .cpp | 1,841 | 51 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_color_space.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/color_space.hpp>
int test_saturation()
{
int Error(0);
glm::vec4 Color = glm::saturation(1.0f, glm::vec4(1.0, 0.5, 0.0, 1.0));
return Error;
}
int main()
{
int Error(0);
Error += test_saturation();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_closest_point.cpp | .cpp | 1,682 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_closest_point.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/closest_point.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_common.cpp | .cpp | 1,990 | 55 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_common.cpp
/// @date 2014-09-08 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/common.hpp>
int test_isdenormal()
{
int Error(0);
bool A = glm::isdenormal(1.0f);
glm::bvec1 B = glm::isdenormal(glm::vec1(1.0f));
glm::bvec2 C = glm::isdenormal(glm::vec2(1.0f));
glm::bvec3 D = glm::isdenormal(glm::vec3(1.0f));
glm::bvec4 E = glm::isdenormal(glm::vec4(1.0f));
return Error;
}
int main()
{
int Error(0);
Error += test_isdenormal();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_rotate_normalized_axis.cpp | .cpp | 1,700 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_rotate_normalized_axis.cpp
/// @date 2012-12-13 / 2012-12-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/rotate_normalized_axis.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_vector_query.cpp | .cpp | 2,903 | 113 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_vector_query.cpp
/// @date 2011-11-23 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/gtx/vector_query.hpp>
int test_areCollinear()
{
int Error(0);
{
bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f);
Error += TestA ? 0 : 1;
}
return Error;
}
int test_areOrthogonal()
{
int Error(0);
bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int test_isNormalized()
{
int Error(0);
bool TestA = glm::isNormalized(glm::vec4(1, 0, 0, 0), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int test_isNull()
{
int Error(0);
bool TestA = glm::isNull(glm::vec4(0), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int test_areOrthonormal()
{
int Error(0);
bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int main()
{
int Error(0);
Error += test_areCollinear();
Error += test_areOrthogonal();
Error += test_isNormalized();
Error += test_isNull();
Error += test_areOrthonormal();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_euler_angle.cpp | .cpp | 13,453 | 360 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_euler_angle.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
// Code sample from Filippo Ramaciotti
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtx/string_cast.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <cstdio>
namespace test_eulerAngleX
{
int test()
{
int Error = 0;
float const Angle(glm::pi<float>() * 0.5f);
glm::vec3 const X(1.0f, 0.0f, 0.0f);
glm::vec4 const Y(0.0f, 1.0f, 0.0f, 1.0f);
glm::vec4 const Y1 = glm::rotate(glm::mat4(1.0f), Angle, X) * Y;
glm::vec4 const Y2 = glm::eulerAngleX(Angle) * Y;
glm::vec4 const Y3 = glm::eulerAngleXY(Angle, 0.0f) * Y;
glm::vec4 const Y4 = glm::eulerAngleYX(0.0f, Angle) * Y;
glm::vec4 const Y5 = glm::eulerAngleXZ(Angle, 0.0f) * Y;
glm::vec4 const Y6 = glm::eulerAngleZX(0.0f, Angle) * Y;
glm::vec4 const Y7 = glm::eulerAngleYXZ(0.0f, Angle, 0.0f) * Y;
Error += glm::all(glm::epsilonEqual(Y1, Y2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Y1, Y3, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Y1, Y4, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Y1, Y5, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Y1, Y6, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Y1, Y7, 0.00001f)) ? 0 : 1;
glm::vec4 const Z(0.0f, 0.0f, 1.0f, 1.0f);
glm::vec4 const Z1 = glm::rotate(glm::mat4(1.0f), Angle, X) * Z;
glm::vec4 const Z2 = glm::eulerAngleX(Angle) * Z;
glm::vec4 const Z3 = glm::eulerAngleXY(Angle, 0.0f) * Z;
glm::vec4 const Z4 = glm::eulerAngleYX(0.0f, Angle) * Z;
glm::vec4 const Z5 = glm::eulerAngleXZ(Angle, 0.0f) * Z;
glm::vec4 const Z6 = glm::eulerAngleZX(0.0f, Angle) * Z;
glm::vec4 const Z7 = glm::eulerAngleYXZ(0.0f, Angle, 0.0f) * Z;
Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleX
namespace test_eulerAngleY
{
int test()
{
int Error = 0;
float const Angle(glm::pi<float>() * 0.5f);
glm::vec3 const Y(0.0f, 1.0f, 0.0f);
glm::vec4 const X(1.0f, 0.0f, 0.0f, 1.0f);
glm::vec4 const X1 = glm::rotate(glm::mat4(1.0f), Angle, Y) * X;
glm::vec4 const X2 = glm::eulerAngleY(Angle) * X;
glm::vec4 const X3 = glm::eulerAngleYX(Angle, 0.0f) * X;
glm::vec4 const X4 = glm::eulerAngleXY(0.0f, Angle) * X;
glm::vec4 const X5 = glm::eulerAngleYZ(Angle, 0.0f) * X;
glm::vec4 const X6 = glm::eulerAngleZY(0.0f, Angle) * X;
glm::vec4 const X7 = glm::eulerAngleYXZ(Angle, 0.0f, 0.0f) * X;
Error += glm::all(glm::epsilonEqual(X1, X2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X3, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X4, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X5, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X6, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X7, 0.00001f)) ? 0 : 1;
glm::vec4 const Z(0.0f, 0.0f, 1.0f, 1.0f);
glm::vec4 const Z1 = glm::eulerAngleY(Angle) * Z;
glm::vec4 const Z2 = glm::rotate(glm::mat4(1.0f), Angle, Y) * Z;
glm::vec4 const Z3 = glm::eulerAngleYX(Angle, 0.0f) * Z;
glm::vec4 const Z4 = glm::eulerAngleXY(0.0f, Angle) * Z;
glm::vec4 const Z5 = glm::eulerAngleYZ(Angle, 0.0f) * Z;
glm::vec4 const Z6 = glm::eulerAngleZY(0.0f, Angle) * Z;
glm::vec4 const Z7 = glm::eulerAngleYXZ(Angle, 0.0f, 0.0f) * Z;
Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleY
namespace test_eulerAngleZ
{
int test()
{
int Error = 0;
float const Angle(glm::pi<float>() * 0.5f);
glm::vec3 const Z(0.0f, 0.0f, 1.0f);
glm::vec4 const X(1.0f, 0.0f, 0.0f, 1.0f);
glm::vec4 const X1 = glm::rotate(glm::mat4(1.0f), Angle, Z) * X;
glm::vec4 const X2 = glm::eulerAngleZ(Angle) * X;
glm::vec4 const X3 = glm::eulerAngleZX(Angle, 0.0f) * X;
glm::vec4 const X4 = glm::eulerAngleXZ(0.0f, Angle) * X;
glm::vec4 const X5 = glm::eulerAngleZY(Angle, 0.0f) * X;
glm::vec4 const X6 = glm::eulerAngleYZ(0.0f, Angle) * X;
glm::vec4 const X7 = glm::eulerAngleYXZ(0.0f, 0.0f, Angle) * X;
Error += glm::all(glm::epsilonEqual(X1, X2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X3, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X4, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X5, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X6, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(X1, X7, 0.00001f)) ? 0 : 1;
glm::vec4 const Y(1.0f, 0.0f, 0.0f, 1.0f);
glm::vec4 const Z1 = glm::rotate(glm::mat4(1.0f), Angle, Z) * Y;
glm::vec4 const Z2 = glm::eulerAngleZ(Angle) * Y;
glm::vec4 const Z3 = glm::eulerAngleZX(Angle, 0.0f) * Y;
glm::vec4 const Z4 = glm::eulerAngleXZ(0.0f, Angle) * Y;
glm::vec4 const Z5 = glm::eulerAngleZY(Angle, 0.0f) * Y;
glm::vec4 const Z6 = glm::eulerAngleYZ(0.0f, Angle) * Y;
glm::vec4 const Z7 = glm::eulerAngleYXZ(0.0f, 0.0f, Angle) * Y;
Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleZ
namespace test_eulerAngleXY
{
int test()
{
int Error = 0;
glm::vec4 const V(1.0f);
float const AngleX(glm::pi<float>() * 0.5f);
float const AngleY(glm::pi<float>() * 0.25f);
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleX, axisX) * glm::rotate(glm::mat4(1.0f), AngleY, axisY)) * V;
glm::vec4 const V2 = glm::eulerAngleXY(AngleX, AngleY) * V;
glm::vec4 const V3 = glm::eulerAngleX(AngleX) * glm::eulerAngleY(AngleY) * V;
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleXY
namespace test_eulerAngleYX
{
int test()
{
int Error = 0;
glm::vec4 const V(1.0f);
float const AngleX(glm::pi<float>() * 0.5f);
float const AngleY(glm::pi<float>() * 0.25f);
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleY, axisY) * glm::rotate(glm::mat4(1.0f), AngleX, axisX)) * V;
glm::vec4 const V2 = glm::eulerAngleYX(AngleY, AngleX) * V;
glm::vec4 const V3 = glm::eulerAngleY(AngleY) * glm::eulerAngleX(AngleX) * V;
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleYX
namespace test_eulerAngleXZ
{
int test()
{
int Error = 0;
glm::vec4 const V(1.0f);
float const AngleX(glm::pi<float>() * 0.5f);
float const AngleZ(glm::pi<float>() * 0.25f);
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleX, axisX) * glm::rotate(glm::mat4(1.0f), AngleZ, axisZ)) * V;
glm::vec4 const V2 = glm::eulerAngleXZ(AngleX, AngleZ) * V;
glm::vec4 const V3 = glm::eulerAngleX(AngleX) * glm::eulerAngleZ(AngleZ) * V;
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleXZ
namespace test_eulerAngleZX
{
int test()
{
int Error = 0;
glm::vec4 const V(1.0f);
float const AngleX(glm::pi<float>() * 0.5f);
float const AngleZ(glm::pi<float>() * 0.25f);
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleZ, axisZ) * glm::rotate(glm::mat4(1.0f), AngleX, axisX)) * V;
glm::vec4 const V2 = glm::eulerAngleZX(AngleZ, AngleX) * V;
glm::vec4 const V3 = glm::eulerAngleZ(AngleZ) * glm::eulerAngleX(AngleX) * V;
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleZX
namespace test_eulerAngleYZ
{
int test()
{
int Error = 0;
glm::vec4 const V(1.0f);
float const AngleY(glm::pi<float>() * 0.5f);
float const AngleZ(glm::pi<float>() * 0.25f);
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleY, axisY) * glm::rotate(glm::mat4(1.0f), AngleZ, axisZ)) * V;
glm::vec4 const V2 = glm::eulerAngleYZ(AngleY, AngleZ) * V;
glm::vec4 const V3 = glm::eulerAngleY(AngleY) * glm::eulerAngleZ(AngleZ) * V;
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleYZ
namespace test_eulerAngleZY
{
int test()
{
int Error = 0;
glm::vec4 const V(1.0f);
float const AngleY(glm::pi<float>() * 0.5f);
float const AngleZ(glm::pi<float>() * 0.25f);
glm::vec3 const axisX(1.0f, 0.0f, 0.0f);
glm::vec3 const axisY(0.0f, 1.0f, 0.0f);
glm::vec3 const axisZ(0.0f, 0.0f, 1.0f);
glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleZ, axisZ) * glm::rotate(glm::mat4(1.0f), AngleY, axisY)) * V;
glm::vec4 const V2 = glm::eulerAngleZY(AngleZ, AngleY) * V;
glm::vec4 const V3 = glm::eulerAngleZ(AngleZ) * glm::eulerAngleY(AngleY) * V;
Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1;
return Error;
}
}//namespace test_eulerAngleZY
namespace test_eulerAngleYXZ
{
int test()
{
glm::f32 first = 1.046f;
glm::f32 second = 0.52f;
glm::f32 third = -0.785f;
glm::fmat4 rotationEuler = glm::eulerAngleYXZ(first, second, third);
glm::fmat4 rotationInvertedY = glm::eulerAngleY(-1.f*first) * glm::eulerAngleX(second) * glm::eulerAngleZ(third);
glm::fmat4 rotationDumb = glm::fmat4();
rotationDumb = glm::rotate(rotationDumb, first, glm::fvec3(0,1,0));
rotationDumb = glm::rotate(rotationDumb, second, glm::fvec3(1,0,0));
rotationDumb = glm::rotate(rotationDumb, third, glm::fvec3(0,0,1));
std::printf("%s\n", glm::to_string(glm::fmat3(rotationEuler)).c_str());
std::printf("%s\n", glm::to_string(glm::fmat3(rotationDumb)).c_str());
std::printf("%s\n", glm::to_string(glm::fmat3(rotationInvertedY)).c_str());
std::printf("\nRESIDUAL\n");
std::printf("%s\n", glm::to_string(glm::fmat3(rotationEuler-(rotationDumb))).c_str());
std::printf("%s\n", glm::to_string(glm::fmat3(rotationEuler-(rotationInvertedY))).c_str());
return 0;
}
}//namespace eulerAngleYXZ
int main()
{
int Error = 0;
Error += test_eulerAngleX::test();
Error += test_eulerAngleY::test();
Error += test_eulerAngleZ::test();
Error += test_eulerAngleXY::test();
Error += test_eulerAngleYX::test();
Error += test_eulerAngleXZ::test();
Error += test_eulerAngleZX::test();
Error += test_eulerAngleYZ::test();
Error += test_eulerAngleZY::test();
Error += test_eulerAngleYXZ::test();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_orthonormalize.cpp | .cpp | 1,684 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_orthonormalize.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/orthonormalize.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_associated_min_max.cpp | .cpp | 1,730 | 41 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_associated_min_max.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/associated_min_max.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_query.cpp | .cpp | 2,541 | 97 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_matrix_query.cpp
/// @date 2011-11-22 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_query.hpp>
int test_isNull()
{
int Error(0);
bool TestA = glm::isNull(glm::mat4(0), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int test_isIdentity()
{
int Error(0);
{
bool TestA = glm::isIdentity(glm::mat2(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::isIdentity(glm::mat3(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::isIdentity(glm::mat4(1), 0.00001f);
Error += TestA ? 0 : 1;
}
return Error;
}
int test_isNormalized()
{
int Error(0);
bool TestA = glm::isNormalized(glm::mat4(1), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int test_isOrthogonal()
{
int Error(0);
bool TestA = glm::isOrthogonal(glm::mat4(1), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int main()
{
int Error(0);
Error += test_isNull();
Error += test_isIdentity();
Error += test_isNormalized();
Error += test_isOrthogonal();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_color_space_YCoCg.cpp | .cpp | 1,690 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_color_space_YCoCg.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/color_space_YCoCg.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_string_cast.cpp | .cpp | 4,943 | 160 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_string_cast.cpp
/// @date 2011-09-01 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include <limits>
int test_string_cast_vector()
{
int Error = 0;
{
glm::vec2 A1(1, 2);
std::string A2 = glm::to_string(A1);
Error += A2 != std::string("vec2(1.000000, 2.000000)") ? 1 : 0;
glm::vec3 B1(1, 2, 3);
std::string B2 = glm::to_string(B1);
Error += B2 != std::string("vec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;
glm::vec4 C1(1, 2, 3, 4);
std::string C2 = glm::to_string(C1);
Error += C2 != std::string("vec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
glm::dvec2 J1(1, 2);
std::string J2 = glm::to_string(J1);
Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0;
glm::dvec3 K1(1, 2, 3);
std::string K2 = glm::to_string(K1);
Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;
glm::dvec4 L1(1, 2, 3, 4);
std::string L2 = glm::to_string(L1);
Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
}
{
glm::bvec2 M1(false, true);
std::string M2 = glm::to_string(M1);
Error += M2 != std::string("bvec2(false, true)") ? 1 : 0;
glm::bvec3 O1(false, true, false);
std::string O2 = glm::to_string(O1);
Error += O2 != std::string("bvec3(false, true, false)") ? 1 : 0;
glm::bvec4 P1(false, true, false, true);
std::string P2 = glm::to_string(P1);
Error += P2 != std::string("bvec4(false, true, false, true)") ? 1 : 0;
}
{
glm::ivec2 D1(1, 2);
std::string D2 = glm::to_string(D1);
Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0;
glm::ivec3 E1(1, 2, 3);
std::string E2 = glm::to_string(E1);
Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0;
glm::ivec4 F1(1, 2, 3, 4);
std::string F2 = glm::to_string(F1);
Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0;
}
{
glm::i8vec2 D1(1, 2);
std::string D2 = glm::to_string(D1);
Error += D2 != std::string("i8vec2(1, 2)") ? 1 : 0;
glm::i8vec3 E1(1, 2, 3);
std::string E2 = glm::to_string(E1);
Error += E2 != std::string("i8vec3(1, 2, 3)") ? 1 : 0;
glm::i8vec4 F1(1, 2, 3, 4);
std::string F2 = glm::to_string(F1);
Error += F2 != std::string("i8vec4(1, 2, 3, 4)") ? 1 : 0;
}
{
glm::i16vec2 D1(1, 2);
std::string D2 = glm::to_string(D1);
Error += D2 != std::string("i16vec2(1, 2)") ? 1 : 0;
glm::i16vec3 E1(1, 2, 3);
std::string E2 = glm::to_string(E1);
Error += E2 != std::string("i16vec3(1, 2, 3)") ? 1 : 0;
glm::i16vec4 F1(1, 2, 3, 4);
std::string F2 = glm::to_string(F1);
Error += F2 != std::string("i16vec4(1, 2, 3, 4)") ? 1 : 0;
}
{
glm::i64vec2 D1(1, 2);
std::string D2 = glm::to_string(D1);
Error += D2 != std::string("i64vec2(1, 2)") ? 1 : 0;
glm::i64vec3 E1(1, 2, 3);
std::string E2 = glm::to_string(E1);
Error += E2 != std::string("i64vec3(1, 2, 3)") ? 1 : 0;
glm::i64vec4 F1(1, 2, 3, 4);
std::string F2 = glm::to_string(F1);
Error += F2 != std::string("i64vec4(1, 2, 3, 4)") ? 1 : 0;
}
return Error;
}
int test_string_cast_matrix()
{
int Error = 0;
glm::mat2x2 A1(1.000000, 2.000000, 3.000000, 4.000000);
std::string A2 = glm::to_string(A1);
Error += A2 != std::string("mat2x2((1.000000, 2.000000), (3.000000, 4.000000))") ? 1 : 0;
return Error;
}
int main()
{
int Error = 0;
Error += test_string_cast_vector();
Error += test_string_cast_matrix();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_optimum_pow.cpp | .cpp | 1,678 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_optimum_pow.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/optimum_pow.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_component_wise.cpp | .cpp | 1,684 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_component_wise.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/component_wise.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_norm.cpp | .cpp | 1,664 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_norm.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/norm.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_compatibility.cpp | .cpp | 1,682 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_compatibility.cpp
/// @date 2014-09-08 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/compatibility.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_rotate_vector.cpp | .cpp | 3,472 | 107 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_rotate_vector.cpp
/// @date 2011-05-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/constants.hpp>
#include <glm/gtx/rotate_vector.hpp>
int test_rotate()
{
int Error = 0;
glm::vec2 A = glm::rotate(glm::vec2(1, 0), glm::pi<float>() * 0.5f);
glm::vec3 B = glm::rotate(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::vec4 C = glm::rotate(glm::vec4(1, 0, 0, 1), glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::vec3 D = glm::rotateX(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f);
glm::vec4 E = glm::rotateX(glm::vec4(1, 0, 0, 1), glm::pi<float>() * 0.5f);
glm::vec3 F = glm::rotateY(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f);
glm::vec4 G = glm::rotateY(glm::vec4(1, 0, 0, 1), glm::pi<float>() * 0.5f);
glm::vec3 H = glm::rotateZ(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f);
glm::vec4 I = glm::rotateZ(glm::vec4(1, 0, 0,1 ), glm::pi<float>() * 0.5f);
glm::mat4 O = glm::orientation(glm::normalize(glm::vec3(1)), glm::vec3(0, 0, 1));
return Error;
}
int test_rotateX()
{
int Error = 0;
glm::vec3 D = glm::rotateX(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f);
glm::vec4 E = glm::rotateX(glm::vec4(1, 0, 0, 1), glm::pi<float>() * 0.5f);
return Error;
}
int test_rotateY()
{
int Error = 0;
glm::vec3 F = glm::rotateY(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f);
glm::vec4 G = glm::rotateY(glm::vec4(1, 0, 0, 1), glm::pi<float>() * 0.5f);
return Error;
}
int test_rotateZ()
{
int Error = 0;
glm::vec3 H = glm::rotateZ(glm::vec3(1, 0, 0), glm::pi<float>() * 0.5f);
glm::vec4 I = glm::rotateZ(glm::vec4(1, 0, 0,1 ), glm::pi<float>() * 0.5f);
return Error;
}
int test_orientation()
{
int Error = 0;
glm::mat4 O = glm::orientation(glm::normalize(glm::vec3(1)), glm::vec3(0, 0, 1));
return Error;
}
int main()
{
int Error = 0;
Error += test_rotate();
Error += test_rotateX();
Error += test_rotateY();
Error += test_rotateZ();
Error += test_orientation();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_vector_angle.cpp | .cpp | 3,433 | 90 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_vector_angle.cpp
/// @date 2011-05-15 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/constants.hpp>
#include <glm/gtx/vector_angle.hpp>
#include <limits>
int test_angle()
{
int Error = 0;
float AngleA = glm::angle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1)));
Error += glm::epsilonEqual(AngleA, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
float AngleB = glm::angle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)));
Error += glm::epsilonEqual(AngleB, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
float AngleC = glm::angle(glm::vec4(1, 0, 0, 0), glm::normalize(glm::vec4(1, 1, 0, 0)));
Error += glm::epsilonEqual(AngleC, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
return Error;
}
int test_orientedAngle_vec2()
{
int Error = 0;
float AngleA = glm::orientedAngle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1)));
Error += AngleA == glm::pi<float>() * 0.25f ? 0 : 1;
float AngleB = glm::orientedAngle(glm::vec2(0, 1), glm::normalize(glm::vec2(1, 1)));
Error += AngleB == -glm::pi<float>() * 0.25f ? 0 : 1;
float AngleC = glm::orientedAngle(glm::normalize(glm::vec2(1, 1)), glm::vec2(0, 1));
Error += AngleC == glm::pi<float>() * 0.25f ? 0 : 1;
return Error;
}
int test_orientedAngle_vec3()
{
int Error = 0;
float AngleA = glm::orientedAngle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 0, 1));
Error += AngleA == glm::pi<float>() * 0.25f ? 0 : 1;
float AngleB = glm::orientedAngle(glm::vec3(0, 1, 0), glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 0, 1));
Error += AngleB == -glm::pi<float>() * 0.25f ? 0 : 1;
float AngleC = glm::orientedAngle(glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 1, 0), glm::vec3(0, 0, 1));
Error += AngleC == glm::pi<float>() * 0.25f ? 0 : 1;
return Error;
}
int main()
{
int Error(0);
Error += test_angle();
Error += test_orientedAngle_vec2();
Error += test_orientedAngle_vec3();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_intersect.cpp | .cpp | 1,674 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_intersect.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/intersect.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_number_precision.cpp | .cpp | 1,688 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_number_precision.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/number_precision.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_quaternion.cpp | .cpp | 3,715 | 134 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_quaternion.cpp
/// @date 2011-05-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/compatibility.hpp>
#include <glm/ext.hpp>
int test_quat_fastMix()
{
int Error = 0;
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::quat C = glm::fastMix(A, B, 0.5f);
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
return Error;
}
int test_quat_shortMix()
{
int Error(0);
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::quat C = glm::shortMix(A, B, 0.5f);
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
return Error;
}
int test_orientation()
{
int Error(0);
{
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
float p = glm::roll(q);
}
{
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
float p = glm::pitch(q);
}
{
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
float p = glm::yaw(q);
}
return Error;
}
int test_rotation()
{
int Error(0);
glm::vec3 v(1, 0, 0);
glm::vec3 u(0, 1, 0);
glm::quat Rotation = glm::rotation(v, u);
float Angle = glm::angle(Rotation);
Error += glm::abs(Angle - glm::pi<float>() * 0.5f) < glm::epsilon<float>() ? 0 : 1;
return Error;
}
int test_log()
{
int Error(0);
glm::quat q;
glm::quat p = glm::log(q);
glm::quat r = glm::exp(p);
return Error;
}
int main()
{
int Error(0);
Error += test_log();
Error += test_rotation();
Error += test_quat_fastMix();
Error += test_quat_shortMix();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_polar_coordinates.cpp | .cpp | 1,690 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_polar_coordinates.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/polar_coordinates.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_scalar_multiplication.cpp | .cpp | 2,350 | 66 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_scalar_multiplication.cpp
/// @date 2014-09-22 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#if GLM_HAS_TEMPLATE_ALIASES & !(GLM_COMPILER & GLM_COMPILER_GCC)
#include <glm/gtx/scalar_multiplication.hpp>
int main()
{
int Error(0);
glm::vec3 v(0.5, 3.1, -9.1);
Error += glm::all(glm::equal(v, 1.0 * v)) ? 0 : 1;
Error += glm::all(glm::equal(v, 1 * v)) ? 0 : 1;
Error += glm::all(glm::equal(v, 1u * v)) ? 0 : 1;
glm::mat3 m(1, 2, 3, 4, 5, 6, 7, 8, 9);
glm::vec3 w = 0.5f * m * v;
Error += glm::all(glm::equal((m*v)/2, w)) ? 0 : 1;
Error += glm::all(glm::equal(m*(v/2), w)) ? 0 : 1;
Error += glm::all(glm::equal((m/2)*v, w)) ? 0 : 1;
Error += glm::all(glm::equal((0.5*m)*v, w)) ? 0 : 1;
Error += glm::all(glm::equal(0.5*(m*v), w)) ? 0 : 1;
return Error;
}
#else
int main()
{
return 0;
}
#endif
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_major_storage.cpp | .cpp | 1,696 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_matrix_major_storage.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_major_storage.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_range.cpp | .cpp | 2,355 | 84 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_range.cpp
/// @date 2014-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtc/epsilon.hpp>
#if GLM_HAS_RANGE_FOR
#include <glm/gtx/range.hpp>
int testVec()
{
int Error(0);
glm::vec3 v(1, 2, 3);
int count = 0;
for(float x : v){ count++; }
Error += count == 3 ? 0 : 1;
for(float& x : v){ x = 0; }
Error += glm::all(glm::equal(v, glm::vec3(0, 0, 0))) ? 0 : 1;
return Error;
}
int testMat()
{
int Error(0);
glm::mat4x3 m(1);
int count = 0;
for(float x : m){ count++; }
Error += count == 12 ? 0 : 1;
for(float& x : m){ x = 0; }
glm::vec4 v(1, 1, 1, 1);
Error += glm::all(glm::equal(m*v, glm::vec3(0, 0, 0))) ? 0 : 1;
return Error;
}
int main()
{
int Error(0);
Error += testVec();
Error += testMat();
return Error;
}
#else
int main()
{
return 0;
}
#endif//GLM_HAS_RANGE_FOR
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_fast_exponential.cpp | .cpp | 1,688 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_fast_exponential.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/fast_exponential.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_io.cpp | .cpp | 9,093 | 211 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_io.cpp
/// @date 2013-11-22 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/io.hpp>
#include <iostream>
#include <sstream>
#include <typeinfo>
namespace
{
template <typename CTy, typename CTr>
std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, glm::precision const& a)
{
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
if (cerberus)
{
switch (a) {
case glm::highp: os << "hi"; break;
case glm::mediump: os << "md"; break;
case glm::lowp: os << "lo"; break;
}
}
return os;
}
template <typename U, glm::precision P, typename T, typename CTy, typename CTr>
std::basic_string<CTy> type_name(std::basic_ostream<CTy,CTr>& os, T const&)
{
std::basic_ostringstream<CTy,CTr> ostr;
if (typeid(T) == typeid(glm::tquat<U,P>)) { ostr << "quat"; }
else if (typeid(T) == typeid(glm::tvec2<U,P>)) { ostr << "vec2"; }
else if (typeid(T) == typeid(glm::tvec3<U,P>)) { ostr << "vec3"; }
else if (typeid(T) == typeid(glm::tvec4<U,P>)) { ostr << "vec4"; }
else if (typeid(T) == typeid(glm::tmat2x2<U,P>)) { ostr << "mat2x2"; }
else if (typeid(T) == typeid(glm::tmat2x3<U,P>)) { ostr << "mat2x3"; }
else if (typeid(T) == typeid(glm::tmat2x4<U,P>)) { ostr << "mat2x4"; }
else if (typeid(T) == typeid(glm::tmat3x2<U,P>)) { ostr << "mat3x2"; }
else if (typeid(T) == typeid(glm::tmat3x3<U,P>)) { ostr << "mat3x3"; }
else if (typeid(T) == typeid(glm::tmat3x4<U,P>)) { ostr << "mat3x4"; }
else if (typeid(T) == typeid(glm::tmat4x2<U,P>)) { ostr << "mat4x2"; }
else if (typeid(T) == typeid(glm::tmat4x3<U,P>)) { ostr << "mat4x3"; }
else if (typeid(T) == typeid(glm::tmat4x4<U,P>)) { ostr << "mat4x4"; }
else { ostr << "unknown"; }
ostr << '<' << typeid(U).name() << ',' << P << '>';
return ostr.str();
}
} // namespace {
template <typename T, glm::precision P, typename OS>
int test_io_quat(OS& os)
{
os << '\n' << typeid(OS).name() << '\n';
glm::tquat<T,P> const q(1, 0, 0, 0);
{
glm::io::basic_format_saver<typename OS::char_type> const iofs(os);
os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2)
<< type_name<T,P>(os, q) << ": " << q << '\n';
}
{
glm::io::basic_format_saver<typename OS::char_type> const iofs(os);
os << glm::io::unformatted
<< type_name<T,P>(os, q) << ": " << q << '\n';
}
return 0;
}
template <typename T, glm::precision P, typename OS>
int test_io_vec(OS& os)
{
os << '\n' << typeid(OS).name() << '\n';
glm::tvec2<T,P> const v2(0, 1);
glm::tvec3<T,P> const v3(2, 3, 4);
glm::tvec4<T,P> const v4(5, 6, 7, 8);
os << type_name<T,P>(os, v2) << ": " << v2 << '\n'
<< type_name<T,P>(os, v3) << ": " << v3 << '\n'
<< type_name<T,P>(os, v4) << ": " << v4 << '\n';
glm::io::basic_format_saver<typename OS::char_type> const iofs(os);
os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2)
<< type_name<T,P>(os, v2) << ": " << v2 << '\n'
<< type_name<T,P>(os, v3) << ": " << v3 << '\n'
<< type_name<T,P>(os, v4) << ": " << v4 << '\n';
return 0;
}
template <typename T, glm::precision P, typename OS>
int test_io_mat(OS& os)
{
os << '\n' << typeid(OS).name() << '\n';
glm::tvec2<T,P> const v2_1( 0, 1);
glm::tvec2<T,P> const v2_2( 2, 3);
glm::tvec2<T,P> const v2_3( 4, 5);
glm::tvec2<T,P> const v2_4( 6, 7);
glm::tvec3<T,P> const v3_1( 8, 9, 10);
glm::tvec3<T,P> const v3_2(11, 12, 13);
glm::tvec3<T,P> const v3_3(14, 15, 16);
glm::tvec3<T,P> const v3_4(17, 18, 19);
glm::tvec4<T,P> const v4_1(20, 21, 22, 23);
glm::tvec4<T,P> const v4_2(24, 25, 26, 27);
glm::tvec4<T,P> const v4_3(28, 29, 30, 31);
glm::tvec4<T,P> const v4_4(32, 33, 34, 35);
#if 0
os << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n'
<< "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n'
<< "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2<T,P>(v2_1, v2_2, v2_3) << '\n'
<< "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3<T,P>(v3_1, v3_2, v3_3) << '\n'
<< "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4<T,P>(v4_1, v4_2, v4_3) << '\n'
<< "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2<T,P>(v2_1, v2_2, v2_3, v2_4) << '\n'
<< "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3<T,P>(v3_1, v3_2, v3_3, v3_4) << '\n'
<< "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';
#endif
glm::io::basic_format_saver<typename OS::char_type> const iofs(os);
os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2)
<< "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n'
<< "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n'
<< "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2<T,P>(v2_1, v2_2, v2_3) << '\n'
<< "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3<T,P>(v3_1, v3_2, v3_3) << '\n'
<< "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4<T,P>(v4_1, v4_2, v4_3) << '\n'
<< "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2<T,P>(v2_1, v2_2, v2_3, v2_4) << '\n'
<< "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3<T,P>(v3_1, v3_2, v3_3, v3_4) << '\n'
<< "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';
os << glm::io::unformatted
<< glm::io::order(glm::io::column_major)
<< "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2<T,P>(v2_1, v2_2) << '\n'
<< "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3<T,P>(v3_1, v3_2) << '\n'
<< "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4<T,P>(v4_1, v4_2) << '\n'
<< "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2<T,P>(v2_1, v2_2, v2_3) << '\n'
<< "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3<T,P>(v3_1, v3_2, v3_3) << '\n'
<< "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4<T,P>(v4_1, v4_2, v4_3) << '\n'
<< "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2<T,P>(v2_1, v2_2, v2_3, v2_4) << '\n'
<< "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3<T,P>(v3_1, v3_2, v3_3, v3_4) << '\n'
<< "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';
return 0;
}
int main()
{
int Error(0);
Error += test_io_quat<float, glm::highp>(std::cout);
Error += test_io_quat<float, glm::highp>(std::wcout);
Error += test_io_quat<int, glm::mediump>(std::cout);
Error += test_io_quat<int, glm::mediump>(std::wcout);
Error += test_io_quat<glm::uint, glm::lowp>(std::cout);
Error += test_io_quat<glm::uint, glm::lowp>(std::wcout);
Error += test_io_vec<float, glm::highp>(std::cout);
Error += test_io_vec<float, glm::highp>(std::wcout);
Error += test_io_vec<int, glm::mediump>(std::cout);
Error += test_io_vec<int, glm::mediump>(std::wcout);
Error += test_io_vec<glm::uint, glm::lowp>(std::cout);
Error += test_io_vec<glm::uint, glm::lowp>(std::wcout);
Error += test_io_mat<float, glm::highp>(std::cout);
Error += test_io_mat<float, glm::lowp>(std::wcout);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_scalar_relational.cpp | .cpp | 5,898 | 202 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_scalar_relational.cpp
/// @date 2013-02-04 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/scalar_relational.hpp>
#include <cstdio>
int test_lessThan()
{
int Error(0);
Error += glm::lessThan(0, 1) ? 0 : 1;
Error += glm::lessThan(1, 0) ? 1 : 0;
Error += glm::lessThan(0, 0) ? 1 : 0;
Error += glm::lessThan(1, 1) ? 1 : 0;
Error += glm::lessThan(0.0f, 1.0f) ? 0 : 1;
Error += glm::lessThan(1.0f, 0.0f) ? 1 : 0;
Error += glm::lessThan(0.0f, 0.0f) ? 1 : 0;
Error += glm::lessThan(1.0f, 1.0f) ? 1 : 0;
Error += glm::lessThan(0.0, 1.0) ? 0 : 1;
Error += glm::lessThan(1.0, 0.0) ? 1 : 0;
Error += glm::lessThan(0.0, 0.0) ? 1 : 0;
Error += glm::lessThan(1.0, 1.0) ? 1 : 0;
return Error;
}
int test_lessThanEqual()
{
int Error(0);
Error += glm::lessThanEqual(0, 1) ? 0 : 1;
Error += glm::lessThanEqual(1, 0) ? 1 : 0;
Error += glm::lessThanEqual(0, 0) ? 0 : 1;
Error += glm::lessThanEqual(1, 1) ? 0 : 1;
Error += glm::lessThanEqual(0.0f, 1.0f) ? 0 : 1;
Error += glm::lessThanEqual(1.0f, 0.0f) ? 1 : 0;
Error += glm::lessThanEqual(0.0f, 0.0f) ? 0 : 1;
Error += glm::lessThanEqual(1.0f, 1.0f) ? 0 : 1;
Error += glm::lessThanEqual(0.0, 1.0) ? 0 : 1;
Error += glm::lessThanEqual(1.0, 0.0) ? 1 : 0;
Error += glm::lessThanEqual(0.0, 0.0) ? 0 : 1;
Error += glm::lessThanEqual(1.0, 1.0) ? 0 : 1;
return Error;
}
int test_greaterThan()
{
int Error(0);
Error += glm::greaterThan(0, 1) ? 1 : 0;
Error += glm::greaterThan(1, 0) ? 0 : 1;
Error += glm::greaterThan(0, 0) ? 1 : 0;
Error += glm::greaterThan(1, 1) ? 1 : 0;
Error += glm::greaterThan(0.0f, 1.0f) ? 1 : 0;
Error += glm::greaterThan(1.0f, 0.0f) ? 0 : 1;
Error += glm::greaterThan(0.0f, 0.0f) ? 1 : 0;
Error += glm::greaterThan(1.0f, 1.0f) ? 1 : 0;
Error += glm::greaterThan(0.0, 1.0) ? 1 : 0;
Error += glm::greaterThan(1.0, 0.0) ? 0 : 1;
Error += glm::greaterThan(0.0, 0.0) ? 1 : 0;
Error += glm::greaterThan(1.0, 1.0) ? 1 : 0;
return Error;
}
int test_greaterThanEqual()
{
int Error(0);
Error += glm::greaterThanEqual(0, 1) ? 1 : 0;
Error += glm::greaterThanEqual(1, 0) ? 0 : 1;
Error += glm::greaterThanEqual(0, 0) ? 0 : 1;
Error += glm::greaterThanEqual(1, 1) ? 0 : 1;
Error += glm::greaterThanEqual(0.0f, 1.0f) ? 1 : 0;
Error += glm::greaterThanEqual(1.0f, 0.0f) ? 0 : 1;
Error += glm::greaterThanEqual(0.0f, 0.0f) ? 0 : 1;
Error += glm::greaterThanEqual(1.0f, 1.0f) ? 0 : 1;
Error += glm::greaterThanEqual(0.0, 1.0) ? 1 : 0;
Error += glm::greaterThanEqual(1.0, 0.0) ? 0 : 1;
Error += glm::greaterThanEqual(0.0, 0.0) ? 0 : 1;
Error += glm::greaterThanEqual(1.0, 1.0) ? 0 : 1;
return Error;
}
int test_equal()
{
int Error(0);
Error += glm::equal(0, 1) ? 1 : 0;
Error += glm::equal(1, 0) ? 1 : 0;
Error += glm::equal(0, 0) ? 0 : 1;
Error += glm::equal(1, 1) ? 0 : 1;
Error += glm::equal(0.0f, 1.0f) ? 1 : 0;
Error += glm::equal(1.0f, 0.0f) ? 1 : 0;
Error += glm::equal(0.0f, 0.0f) ? 0 : 1;
Error += glm::equal(1.0f, 1.0f) ? 0 : 1;
Error += glm::equal(0.0, 1.0) ? 1 : 0;
Error += glm::equal(1.0, 0.0) ? 1 : 0;
Error += glm::equal(0.0, 0.0) ? 0 : 1;
Error += glm::equal(1.0, 1.0) ? 0 : 1;
return Error;
}
int test_notEqual()
{
int Error(0);
Error += glm::notEqual(0, 1) ? 0 : 1;
Error += glm::notEqual(1, 0) ? 0 : 1;
Error += glm::notEqual(0, 0) ? 1 : 0;
Error += glm::notEqual(1, 1) ? 1 : 0;
Error += glm::notEqual(0.0f, 1.0f) ? 0 : 1;
Error += glm::notEqual(1.0f, 0.0f) ? 0 : 1;
Error += glm::notEqual(0.0f, 0.0f) ? 1 : 0;
Error += glm::notEqual(1.0f, 1.0f) ? 1 : 0;
Error += glm::notEqual(0.0, 1.0) ? 0 : 1;
Error += glm::notEqual(1.0, 0.0) ? 0 : 1;
Error += glm::notEqual(0.0, 0.0) ? 1 : 0;
Error += glm::notEqual(1.0, 1.0) ? 1 : 0;
return Error;
}
int test_any()
{
int Error(0);
Error += glm::any(true) ? 0 : 1;
Error += glm::any(false) ? 1 : 0;
return Error;
}
int test_all()
{
int Error(0);
Error += glm::all(true) ? 0 : 1;
Error += glm::all(false) ? 1 : 0;
return Error;
}
int test_not()
{
int Error(0);
Error += glm::not_(true) ? 1 : 0;
Error += glm::not_(false) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_lessThan();
Error += test_lessThanEqual();
Error += test_greaterThan();
Error += test_greaterThanEqual();
Error += test_equal();
Error += test_notEqual();
Error += test_any();
Error += test_all();
Error += test_not();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_cross_product.cpp | .cpp | 1,696 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_matrix_cross_product.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_cross_product.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_normal.cpp | .cpp | 1,668 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_normal.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/normal.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_handed_coordinate_space.cpp | .cpp | 1,702 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_handed_coordinate_space.cpp
/// @date 2011-10-13 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/handed_coordinate_space.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_fast_square_root.cpp | .cpp | 3,237 | 77 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_fast_square_root.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/fast_square_root.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp>
int test_fastInverseSqrt()
{
int Error(0);
Error += glm::epsilonEqual(glm::fastInverseSqrt(1.0f), 1.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(glm::fastInverseSqrt(1.0), 1.0, 0.01) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::vec2(1.0f)), glm::vec2(1.0f), 0.01f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::dvec3(1.0)), glm::dvec3(1.0), 0.01)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::dvec4(1.0)), glm::dvec4(1.0), 0.01)) ? 0 : 1;
return 0;
}
int test_fastDistance()
{
int Error(0);
glm::mediump_f32 A = glm::fastDistance(glm::mediump_f32(0.0f), glm::mediump_f32(1.0f));
glm::mediump_f32 B = glm::fastDistance(glm::mediump_f32vec2(0.0f), glm::mediump_f32vec2(1.0f, 0.0f));
glm::mediump_f32 C = glm::fastDistance(glm::mediump_f32vec3(0.0f), glm::mediump_f32vec3(1.0f, 0.0f, 0.0f));
glm::mediump_f32 D = glm::fastDistance(glm::mediump_f32vec4(0.0f), glm::mediump_f32vec4(1.0f, 0.0f, 0.0f, 0.0f));
Error += glm::epsilonEqual(A, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1;
Error += glm::epsilonEqual(B, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1;
Error += glm::epsilonEqual(C, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1;
Error += glm::epsilonEqual(D, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1;
return Error;
}
int main()
{
int Error(0);
Error += test_fastInverseSqrt();
Error += test_fastDistance();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_type_aligned.cpp | .cpp | 3,298 | 145 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_type_aligned.cpp
/// @date 2014-11-23 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/type_aligned.hpp>
#include <cstdio>
int test_decl()
{
int Error(0);
{
struct S1
{
glm::aligned_vec4 B;
};
struct S2
{
glm::vec4 B;
};
printf("vec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2));
Error += sizeof(S1) >= sizeof(S2) ? 0 : 1;
}
{
struct S1
{
bool A;
glm::vec3 B;
};
struct S2
{
bool A;
glm::aligned_vec3 B;
};
printf("vec3: %d, aligned: %d\n", sizeof(S1), sizeof(S2));
Error += sizeof(S1) <= sizeof(S2) ? 0 : 1;
}
{
struct S1
{
bool A;
glm::aligned_vec4 B;
};
struct S2
{
bool A;
glm::vec4 B;
};
printf("vec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2));
Error += sizeof(S1) >= sizeof(S2) ? 0 : 1;
}
{
struct S1
{
bool A;
glm::aligned_dvec4 B;
};
struct S2
{
bool A;
glm::dvec4 B;
};
printf("dvec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2));
Error += sizeof(S1) >= sizeof(S2) ? 0 : 1;
}
return Error;
}
template <typename genType>
void print(genType const & Mat0)
{
printf("mat4(\n");
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]);
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]);
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]);
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
}
int perf_mul()
{
int Error = 0;
glm::mat4 A(1.0f);
glm::mat4 B(1.0f);
glm::mat4 C = A * B;
print(C);
return Error;
}
int main()
{
int Error(0);
Error += test_decl();
Error += perf_mul();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_gradient_paint.cpp | .cpp | 2,138 | 65 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_gradient_paint.cpp
/// @date 2011-10-13 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/gradient_paint.hpp>
int test_radialGradient()
{
int Error = 0;
float Gradient = glm::radialGradient(glm::vec2(0), 1.0f, glm::vec2(1), glm::vec2(0.5));
Error += Gradient != 0.0f ? 0 : 1;
return Error;
}
int test_linearGradient()
{
int Error = 0;
float Gradient = glm::linearGradient(glm::vec2(0), glm::vec2(1), glm::vec2(0.5));
Error += Gradient != 0.0f ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_radialGradient();
Error += test_linearGradient();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_extend.cpp | .cpp | 1,668 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_extend.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/extend.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_dual_quaternion.cpp | .cpp | 7,586 | 220 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_dual_quaternion.cpp
/// @date 2013-02-10 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/dual_quaternion.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/vector_relational.hpp>
#if GLM_HAS_TRIVIAL_QUERIES
# include <type_traits>
#endif
int myrand()
{
static int holdrand = 1;
return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
}
float myfrand() // returns values from -1 to 1 inclusive
{
return float(double(myrand()) / double( 0x7ffff )) * 2.0f - 1.0f;
}
int test_dquat_type()
{
glm::dvec3 vA;
glm::dquat dqA,dqB;
glm::ddualquat C(dqA,dqB);
glm::ddualquat B(dqA);
glm::ddualquat D(dqA,vA);
return 0;
}
int test_scalars()
{
float const Epsilon = 0.0001f;
int Error(0);
glm::quat src_q1 = glm::quat(1.0f,2.0f,3.0f,4.0f);
glm::quat src_q2 = glm::quat(5.0f,6.0f,7.0f,8.0f);
glm::dualquat src1(src_q1,src_q2);
{
glm::dualquat dst1 = src1 * 2.0f;
glm::dualquat dst2 = 2.0f * src1;
glm::dualquat dst3 = src1;
dst3 *= 2.0f;
glm::dualquat dstCmp(src_q1 * 2.0f,src_q2 * 2.0f);
Error += glm::all(glm::epsilonEqual(dst1.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst1.dual,dstCmp.dual, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(dst2.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst2.dual,dstCmp.dual, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(dst3.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst3.dual,dstCmp.dual, Epsilon)) ? 0 : 1;
}
{
glm::dualquat dst1 = src1 / 2.0f;
glm::dualquat dst2 = src1;
dst2 /= 2.0f;
glm::dualquat dstCmp(src_q1 / 2.0f,src_q2 / 2.0f);
Error += glm::all(glm::epsilonEqual(dst1.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst1.dual,dstCmp.dual, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(dst2.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst2.dual,dstCmp.dual, Epsilon)) ? 0 : 1;
}
return Error;
}
int test_inverse()
{
int Error(0);
float const Epsilon = 0.0001f;
glm::dualquat dqid;
glm::mat4x4 mid(1.0f);
for (int j = 0; j < 100; ++j)
{
glm::mat4x4 rot = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f);
glm::vec3 vt = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f);
glm::mat4x4 m = glm::translate(mid, vt) * rot;
glm::quat qr = glm::quat_cast(m);
glm::dualquat dq(qr);
glm::dualquat invdq = glm::inverse(dq);
glm::dualquat r1 = invdq * dq;
glm::dualquat r2 = dq * invdq;
Error += glm::all(glm::epsilonEqual(r1.real, dqid.real, Epsilon)) && glm::all(glm::epsilonEqual(r1.dual, dqid.dual, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(r2.real, dqid.real, Epsilon)) && glm::all(glm::epsilonEqual(r2.dual, dqid.dual, Epsilon)) ? 0 : 1;
// testing commutative property
glm::dualquat r ( glm::quat( myfrand() * glm::pi<float>() * 2.0f, myfrand(), myfrand(), myfrand() ),
glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f) );
glm::dualquat riq = (r * invdq) * dq;
glm::dualquat rqi = (r * dq) * invdq;
Error += glm::all(glm::epsilonEqual(riq.real, rqi.real, Epsilon)) && glm::all(glm::epsilonEqual(riq.dual, rqi.dual, Epsilon)) ? 0 : 1;
}
return Error;
}
int test_mul()
{
int Error(0);
float const Epsilon = 0.0001f;
glm::mat4x4 mid(1.0f);
for (int j = 0; j < 100; ++j)
{
// generate random rotations and translations and compare transformed by matrix and dualquats random points
glm::vec3 vt1 = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f);
glm::vec3 vt2 = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f);
glm::mat4x4 rot1 = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f);
glm::mat4x4 rot2 = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f);
glm::mat4x4 m1 = glm::translate(mid, vt1) * rot1;
glm::mat4x4 m2 = glm::translate(mid, vt2) * rot2;
glm::mat4x4 m3 = m2 * m1;
glm::mat4x4 m4 = m1 * m2;
glm::quat qrot1 = glm::quat_cast(rot1);
glm::quat qrot2 = glm::quat_cast(rot2);
glm::dualquat dq1 = glm::dualquat(qrot1,vt1);
glm::dualquat dq2 = glm::dualquat(qrot2,vt2);
glm::dualquat dq3 = dq2 * dq1;
glm::dualquat dq4 = dq1 * dq2;
for (int i = 0; i < 100; ++i)
{
glm::vec4 src_pt = glm::vec4(myfrand() * 4.0f, myfrand() * 5.0f, myfrand() * 3.0f,1.0f);
// test both multiplication orders
glm::vec4 dst_pt_m3 = m3 * src_pt;
glm::vec4 dst_pt_dq3 = dq3 * src_pt;
glm::vec4 dst_pt_m3_i = glm::inverse(m3) * src_pt;
glm::vec4 dst_pt_dq3_i = src_pt * dq3;
glm::vec4 dst_pt_m4 = m4 * src_pt;
glm::vec4 dst_pt_dq4 = dq4 * src_pt;
glm::vec4 dst_pt_m4_i = glm::inverse(m4) * src_pt;
glm::vec4 dst_pt_dq4_i = src_pt * dq4;
Error += glm::all(glm::epsilonEqual(dst_pt_m3, dst_pt_dq3, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(dst_pt_m4, dst_pt_dq4, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(dst_pt_m3_i, dst_pt_dq3_i, Epsilon)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(dst_pt_m4_i, dst_pt_dq4_i, Epsilon)) ? 0 : 1;
}
}
return Error;
}
int test_dual_quat_ctr()
{
int Error(0);
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::dualquat>::value ? 0 : 1;
// Error += std::is_trivially_default_constructible<glm::ddualquat>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::dualquat>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::ddualquat>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dualquat>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::ddualquat>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::dualquat>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::ddualquat>::value ? 0 : 1;
# endif
return Error;
}
int main()
{
int Error(0);
Error += test_dual_quat_ctr();
Error += test_dquat_type();
Error += test_scalars();
Error += test_inverse();
Error += test_mul();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_multiple.cpp | .cpp | 7,566 | 176 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_multiple.cpp
/// @date 2012-11-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/multiple.hpp>
int test_higher_uint()
{
int Error(0);
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(0), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(1), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(2), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(3), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(4), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(5), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(6), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(7), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(8), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(9), glm::uvec4(4)), glm::uvec4(12))) ? 0 : 1;
return Error;
}
int test_Lower_uint()
{
int Error(0);
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(0), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(1), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(2), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(3), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(4), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(5), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(6), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(7), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(8), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(9), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
return Error;
}
int test_higher_int()
{
int Error(0);
Error += glm::higherMultiple(-5, 4) == -4 ? 0 : 1;
Error += glm::higherMultiple(-4, 4) == -4 ? 0 : 1;
Error += glm::higherMultiple(-3, 4) == 0 ? 0 : 1;
Error += glm::higherMultiple(-2, 4) == 0 ? 0 : 1;
Error += glm::higherMultiple(-1, 4) == 0 ? 0 : 1;
Error += glm::higherMultiple(0, 4) == 0 ? 0 : 1;
Error += glm::higherMultiple(1, 4) == 4 ? 0 : 1;
Error += glm::higherMultiple(2, 4) == 4 ? 0 : 1;
Error += glm::higherMultiple(3, 4) == 4 ? 0 : 1;
Error += glm::higherMultiple(4, 4) == 4 ? 0 : 1;
Error += glm::higherMultiple(5, 4) == 8 ? 0 : 1;
Error += glm::higherMultiple(6, 4) == 8 ? 0 : 1;
Error += glm::higherMultiple(7, 4) == 8 ? 0 : 1;
Error += glm::higherMultiple(8, 4) == 8 ? 0 : 1;
Error += glm::higherMultiple(9, 4) == 12 ? 0 : 1;
return Error;
}
int test_Lower_int()
{
int Error(0);
Error += glm::lowerMultiple(-5, 4) == -8 ? 0 : 1;
Error += glm::lowerMultiple(-4, 4) == -4 ? 0 : 1;
Error += glm::lowerMultiple(-3, 4) == -4 ? 0 : 1;
Error += glm::lowerMultiple(-2, 4) == -4 ? 0 : 1;
Error += glm::lowerMultiple(-1, 4) == -4 ? 0 : 1;
Error += glm::lowerMultiple(0, 4) == 0 ? 0 : 1;
Error += glm::lowerMultiple(1, 4) == 0 ? 0 : 1;
Error += glm::lowerMultiple(2, 4) == 0 ? 0 : 1;
Error += glm::lowerMultiple(3, 4) == 0 ? 0 : 1;
Error += glm::lowerMultiple(4, 4) == 4 ? 0 : 1;
Error += glm::lowerMultiple(5, 4) == 4 ? 0 : 1;
Error += glm::lowerMultiple(6, 4) == 4 ? 0 : 1;
Error += glm::lowerMultiple(7, 4) == 4 ? 0 : 1;
Error += glm::lowerMultiple(8, 4) == 8 ? 0 : 1;
Error += glm::lowerMultiple(9, 4) == 8 ? 0 : 1;
return Error;
}
int test_higher_double()
{
int Error(0);
Error += glm::higherMultiple(-9.0, 4.0) == -8.0 ? 0 : 1;
Error += glm::higherMultiple(-5.0, 4.0) == -4.0 ? 0 : 1;
Error += glm::higherMultiple(-4.0, 4.0) == -4.0 ? 0 : 1;
Error += glm::higherMultiple(-3.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::higherMultiple(-2.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::higherMultiple(-1.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::higherMultiple(0.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::higherMultiple(1.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::higherMultiple(2.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::higherMultiple(3.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::higherMultiple(4.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::higherMultiple(5.0, 4.0) == 8.0 ? 0 : 1;
Error += glm::higherMultiple(6.0, 4.0) == 8.0 ? 0 : 1;
Error += glm::higherMultiple(7.0, 4.0) == 8.0 ? 0 : 1;
Error += glm::higherMultiple(8.0, 4.0) == 8.0 ? 0 : 1;
Error += glm::higherMultiple(9.0, 4.0) == 12.0 ? 0 : 1;
return Error;
}
int test_Lower_double()
{
int Error(0);
Error += glm::lowerMultiple(-5.0, 4.0) == -8.0 ? 0 : 1;
Error += glm::lowerMultiple(-4.0, 4.0) == -4.0 ? 0 : 1;
Error += glm::lowerMultiple(-3.0, 4.0) == -4.0 ? 0 : 1;
Error += glm::lowerMultiple(-2.0, 4.0) == -4.0 ? 0 : 1;
Error += glm::lowerMultiple(-1.0, 4.0) == -4.0 ? 0 : 1;
Error += glm::lowerMultiple(0.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::lowerMultiple(1.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::lowerMultiple(2.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::lowerMultiple(3.0, 4.0) == 0.0 ? 0 : 1;
Error += glm::lowerMultiple(4.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::lowerMultiple(5.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::lowerMultiple(6.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::lowerMultiple(7.0, 4.0) == 4.0 ? 0 : 1;
Error += glm::lowerMultiple(8.0, 4.0) == 8.0 ? 0 : 1;
Error += glm::lowerMultiple(9.0, 4.0) == 8.0 ? 0 : 1;
return Error;
}
int main()
{
int Error(0);
Error += test_higher_int();
Error += test_Lower_int();
Error += test_higher_uint();
Error += test_Lower_uint();
Error += test_higher_double();
Error += test_Lower_double();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_perpendicular.cpp | .cpp | 1,682 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_perpendicular.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/perpendicular.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_interpolation.cpp | .cpp | 1,698 | 42 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_matrix_interpolation.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_interpolation.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_random.cpp | .cpp | 2,830 | 100 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-05-31
// Updated : 2011-05-31
// Licence : This source is under MIT licence
// File : test/gtx/random.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/random.hpp>
#include <glm/gtx/epsilon.hpp>
#include <iostream>
int test_signedRand1()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::signedRand1<float>();
ResultDouble += glm::signedRand1<double>();
}
Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f);
Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001);
}
return Error;
}
int test_normalizedRand2()
{
int Error = 0;
{
std::size_t Max = 100000;
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloat += glm::length(glm::normalizedRand2<float>());
ResultDouble += glm::length(glm::normalizedRand2<double>());
}
Error += glm::equalEpsilon(ResultFloat, float(Max), 0.000001f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDouble, double(Max), 0.000001) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_normalizedRand3()
{
int Error = 0;
{
std::size_t Max = 100000;
float ResultFloatA = 0.0f;
float ResultFloatB = 0.0f;
float ResultFloatC = 0.0f;
double ResultDoubleA = 0.0f;
double ResultDoubleB = 0.0f;
double ResultDoubleC = 0.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloatA += glm::length(glm::normalizedRand3<float>());
ResultDoubleA += glm::length(glm::normalizedRand3<double>());
ResultFloatB += glm::length(glm::normalizedRand3(2.0f, 2.0f));
ResultDoubleB += glm::length(glm::normalizedRand3(2.0, 2.0));
ResultFloatC += glm::length(glm::normalizedRand3(1.0f, 3.0f));
ResultDoubleC += glm::length(glm::normalizedRand3(1.0, 3.0));
}
Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.0001f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.0001f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
Error += (ResultFloatC >= float(Max) && ResultFloatC <= float(Max * 3)) ? 0 : 1;
Error += (ResultDoubleC >= double(Max) && ResultDoubleC <= double(Max * 3)) ? 0 : 1;
}
return Error;
}
int main()
{
int Error = 0;
Error += test_signedRand1();
Error += test_normalizedRand2();
Error += test_normalizedRand3();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_log_base.cpp | .cpp | 1,672 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_log_base.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/log_base.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_operation.cpp | .cpp | 1,688 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_matrix_operation.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_operation.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_spline.cpp | .cpp | 3,650 | 131 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_spline.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/gtx/spline.hpp>
namespace catmullRom
{
int test()
{
int Error(0);
glm::vec2 Result2 = glm::catmullRom(
glm::vec2(0.0f, 0.0f),
glm::vec2(1.0f, 0.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(0.0f, 1.0f), 0.5f);
glm::vec3 Result3 = glm::catmullRom(
glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(1.0f, 0.0f, 0.0f),
glm::vec3(1.0f, 1.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f), 0.5f);
glm::vec4 Result4 = glm::catmullRom(
glm::vec4(0.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(1.0f, 1.0f, 0.0f, 1.0f),
glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f);
return Error;
}
}//catmullRom
namespace hermite
{
int test()
{
int Error(0);
glm::vec2 Result2 = glm::hermite(
glm::vec2(0.0f, 0.0f),
glm::vec2(1.0f, 0.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(0.0f, 1.0f), 0.5f);
glm::vec3 Result3 = glm::hermite(
glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(1.0f, 0.0f, 0.0f),
glm::vec3(1.0f, 1.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f), 0.5f);
glm::vec4 Result4 = glm::hermite(
glm::vec4(0.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(1.0f, 1.0f, 0.0f, 1.0f),
glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f);
return Error;
}
}//catmullRom
namespace cubic
{
int test()
{
int Error(0);
glm::vec2 Result2 = glm::cubic(
glm::vec2(0.0f, 0.0f),
glm::vec2(1.0f, 0.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(0.0f, 1.0f), 0.5f);
glm::vec3 Result3 = glm::cubic(
glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(1.0f, 0.0f, 0.0f),
glm::vec3(1.0f, 1.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f), 0.5f);
glm::vec4 Result = glm::cubic(
glm::vec4(0.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
glm::vec4(1.0f, 1.0f, 0.0f, 1.0f),
glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f);
return Error;
}
}//catmullRom
int main()
{
int Error(0);
Error += catmullRom::test();
Error += hermite::test();
Error += cubic::test();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_fast_trigonometry.cpp | .cpp | 6,868 | 192 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_fast_trigonometry.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/fast_trigonometry.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/ulp.hpp>
#include <ctime>
#include <cstdio>
namespace fastCos
{
int perf()
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i=begin; i<end; i = glm::next_float(i, end))
result = glm::fastCos(i);
const std::clock_t timestamp2 = std::clock();
for(float i=begin; i<end; i = glm::next_float(i, end))
result = glm::cos(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastCos Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("cos Time %d clocks\n", static_cast<unsigned int>(time_default));
return time_fast < time_default ? 0 : 1;
}
}//namespace fastCos
namespace fastSin
{
int perf()
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::fastSin(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::sin(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastSin Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("sin Time %d clocks\n", static_cast<unsigned int>(time_default));
return time_fast < time_default ? 0 : 1;
}
}//namespace fastSin
namespace fastTan
{
int perf()
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::fastTan(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::tan(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastTan Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("tan Time %d clocks\n", static_cast<unsigned int>(time_default));
return time_fast < time_default ? 0 : 1;
}
}//namespace fastTan
namespace fastAcos
{
int perf()
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::fastAcos(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::acos(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastAcos Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("acos Time %d clocks\n", static_cast<unsigned int>(time_default));
return time_fast < time_default ? 0 : 1;
}
}//namespace fastAcos
namespace fastAsin
{
int perf()
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::fastAsin(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::asin(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastAsin Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("asin Time %d clocks\n", static_cast<unsigned int>(time_default));
return time_fast < time_default ? 0 : 1;
}
}//namespace fastAsin
namespace fastAtan
{
int perf()
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::fastAtan(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
result = glm::atan(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastAtan Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("atan Time %d clocks\n", static_cast<unsigned int>(time_default));
return time_fast < time_default ? 0 : 1;
}
}//namespace fastAtan
int main()
{
int Error(0);
# ifdef NDEBUG
Error += ::fastCos::perf();
Error += ::fastSin::perf();
Error += ::fastTan::perf();
Error += ::fastAcos::perf();
Error += ::fastAsin::perf();
Error += ::fastAtan::perf();
# endif//NDEBUG
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_extented_min_max.cpp | .cpp | 1,688 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_extented_min_max.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/extented_min_max.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_integer.cpp | .cpp | 2,779 | 96 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_integer.cpp
/// @date 2011-10-11 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/exponential.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtx/integer.hpp>
#include <cstdio>
/*
int test_floor_log2()
{
int Error = 0;
for(std::size_t i = 1; i < 1000000; ++i)
{
glm::uint A = glm::floor_log2(glm::uint(i));
glm::uint B = glm::uint(glm::floor(glm::log2(double(i)))); // Will fail with float, lack of accuracy
Error += A == B ? 0 : 1;
assert(!Error);
}
return Error;
}
*/
int test_log2()
{
int Error = 0;
for(std::size_t i = 1; i < 24; ++i)
{
glm::uint A = glm::log2(glm::uint(1 << i));
glm::uint B = glm::uint(glm::log2(double(1 << i)));
//Error += glm::equalEpsilon(double(A), B, 1.0) ? 0 : 1;
Error += glm::abs(double(A) - B) <= 24 ? 0 : 1;
assert(!Error);
printf("Log2(%d) Error: %d, %d\n", 1 << i, A, B);
}
printf("log2 error: %d\n", Error);
return Error;
}
int test_nlz()
{
int Error = 0;
for(glm::uint i = 1; i < glm::uint(33); ++i)
Error += glm::nlz(i) == glm::uint(31u) - glm::findMSB(i) ? 0 : 1;
//printf("%d, %d\n", glm::nlz(i), 31u - glm::findMSB(i));
return Error;
}
int main()
{
int Error = 0;
Error += test_nlz();
// Error += test_floor_log2();
Error += test_log2();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_mixed_product.cpp | .cpp | 648 | 19 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2013-10-25
// Updated : 2013-10-25
// Licence : This source is under MIT licence
// File : test/gtx/associated_min_max.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/associated_min_max.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_decompose.cpp | .cpp | 1,685 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_decomposition.cpp
/// @date 2014-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_decompose.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_projection.cpp | .cpp | 1,676 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_projection.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/projection.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_simd_mat4.cpp | .cpp | 9,012 | 326 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_simd_mat4.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/random.hpp>
#include <glm/gtx/simd_vec4.hpp>
#include <glm/gtx/simd_mat4.hpp>
#include <cstdio>
#include <ctime>
#include <vector>
#if(GLM_ARCH != GLM_ARCH_PURE)
std::vector<float> test_detA(std::vector<glm::mat4> const & Data)
{
std::vector<float> Test(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Test.size() - 1; ++i)
Test[i] = glm::determinant(Data[i]);
std::clock_t TimeEnd = clock();
printf("Det A: %ld\n", TimeEnd - TimeStart);
return Test;
}
std::vector<float> test_detB(std::vector<glm::mat4> const & Data)
{
std::vector<float> Test(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Test.size() - 1; ++i)
{
_mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0);
glm::simdMat4 m(Data[i]);
glm::simdVec4 d(glm::detail::sse_slow_det_ps((__m128 const * const)&m));
glm::vec4 v;//(d);
Test[i] = v.x;
}
std::clock_t TimeEnd = clock();
printf("Det B: %ld\n", TimeEnd - TimeStart);
return Test;
}
std::vector<float> test_detC(std::vector<glm::mat4> const & Data)
{
std::vector<float> Test(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Test.size() - 1; ++i)
{
_mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0);
glm::simdMat4 m(Data[i]);
glm::simdVec4 d(glm::detail::sse_det_ps((__m128 const * const)&m));
glm::vec4 v;//(d);
Test[i] = v.x;
}
std::clock_t TimeEnd = clock();
printf("Det C: %ld\n", TimeEnd - TimeStart);
return Test;
}
std::vector<float> test_detD(std::vector<glm::mat4> const & Data)
{
std::vector<float> Test(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Test.size() - 1; ++i)
{
_mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0);
glm::simdMat4 m(Data[i]);
glm::simdVec4 d(glm::detail::sse_detd_ps((__m128 const * const)&m));
glm::vec4 v;//(d);
Test[i] = v.x;
}
std::clock_t TimeEnd = clock();
printf("Det D: %ld\n", TimeEnd - TimeStart);
return Test;
}
void test_invA(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
{
//std::vector<float> Test(Data.size());
Out.resize(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Out.size() - 1; ++i)
{
Out[i] = glm::inverse(Data[i]);
}
std::clock_t TimeEnd = clock();
printf("Inv A: %ld\n", TimeEnd - TimeStart);
}
void test_invC(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
{
//std::vector<float> Test(Data.size());
Out.resize(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Out.size() - 1; ++i)
{
_mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0);
glm::simdMat4 m(Data[i]);
glm::simdMat4 o;
glm::detail::sse_inverse_fast_ps((__m128 const * const)&m, (__m128 *)&o);
Out[i] = *(glm::mat4*)&o;
}
std::clock_t TimeEnd = clock();
printf("Inv C: %ld\n", TimeEnd - TimeStart);
}
void test_invD(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
{
//std::vector<float> Test(Data.size());
Out.resize(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Out.size() - 1; ++i)
{
_mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0);
glm::simdMat4 m(Data[i]);
glm::simdMat4 o;
glm::detail::sse_inverse_ps((__m128 const * const)&m, (__m128 *)&o);
Out[i] = *(glm::mat4*)&o;
}
std::clock_t TimeEnd = clock();
printf("Inv D: %ld\n", TimeEnd - TimeStart);
}
void test_mulA(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
{
//std::vector<float> Test(Data.size());
Out.resize(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Out.size() - 1; ++i)
{
Out[i] = Data[i] * Data[i];
}
std::clock_t TimeEnd = clock();
printf("Mul A: %ld\n", TimeEnd - TimeStart);
}
void test_mulD(std::vector<glm::mat4> const & Data, std::vector<glm::mat4> & Out)
{
//std::vector<float> Test(Data.size());
Out.resize(Data.size());
std::clock_t TimeStart = clock();
for(std::size_t i = 0; i < Out.size() - 1; ++i)
{
_mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0);
glm::simdMat4 m(Data[i]);
glm::simdMat4 o;
glm::detail::sse_mul_ps((__m128 const * const)&m, (__m128 const * const)&m, (__m128*)&o);
Out[i] = *(glm::mat4*)&o;
}
std::clock_t TimeEnd = clock();
printf("Mul D: %ld\n", TimeEnd - TimeStart);
}
int test_compute_glm()
{
return 0;
}
int test_compute_gtx()
{
std::vector<glm::vec4> Output(1000000);
std::clock_t TimeStart = clock();
for(std::size_t k = 0; k < Output.size(); ++k)
{
float i = float(k) / 1000.f + 0.001f;
glm::vec3 A = glm::normalize(glm::vec3(i));
glm::vec3 B = glm::cross(A, glm::normalize(glm::vec3(1, 1, 2)));
glm::mat4 C = glm::rotate(glm::mat4(1.0f), i, B);
glm::mat4 D = glm::scale(C, glm::vec3(0.8f, 1.0f, 1.2f));
glm::mat4 E = glm::translate(D, glm::vec3(1.4f, 1.2f, 1.1f));
glm::mat4 F = glm::perspective(i, 1.5f, 0.1f, 1000.f);
glm::mat4 G = glm::inverse(F * E);
glm::vec3 H = glm::unProject(glm::vec3(i), G, F, E[3]);
glm::vec3 I = glm::any(glm::isnan(glm::project(H, G, F, E[3]))) ? glm::vec3(2) : glm::vec3(1);
glm::mat4 J = glm::lookAt(glm::normalize(glm::max(B, glm::vec3(0.001f))), H, I);
glm::mat4 K = glm::transpose(J);
glm::quat L = glm::normalize(glm::quat_cast(K));
glm::vec4 M = L * glm::smoothstep(K[3], J[3], glm::vec4(i));
glm::mat4 N = glm::mat4(glm::normalize(glm::max(M, glm::vec4(0.001f))), K[3], J[3], glm::vec4(i));
glm::mat4 O = N * glm::inverse(N);
glm::vec4 P = O * glm::reflect(N[3], glm::vec4(A, 1.0f));
glm::vec4 Q = glm::vec4(glm::dot(M, P));
glm::vec4 R = glm::quat(Q.w, glm::vec3(Q)) * P;
Output[k] = R;
}
std::clock_t TimeEnd = clock();
printf("test_compute_gtx: %ld\n", TimeEnd - TimeStart);
return 0;
}
int main()
{
int Error = 0;
std::vector<glm::mat4> Data(64 * 64 * 1);
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::mat4(
glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))),
glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))),
glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))),
glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))));
{
std::vector<glm::mat4> TestInvA;
test_invA(Data, TestInvA);
}
{
std::vector<glm::mat4> TestInvC;
test_invC(Data, TestInvC);
}
{
std::vector<glm::mat4> TestInvD;
test_invD(Data, TestInvD);
}
{
std::vector<glm::mat4> TestA;
test_mulA(Data, TestA);
}
{
std::vector<glm::mat4> TestD;
test_mulD(Data, TestD);
}
{
std::vector<float> TestDetA = test_detA(Data);
std::vector<float> TestDetB = test_detB(Data);
std::vector<float> TestDetD = test_detD(Data);
std::vector<float> TestDetC = test_detC(Data);
for(std::size_t i = 0; i < TestDetA.size(); ++i)
if(TestDetA[i] != TestDetB[i] && TestDetC[i] != TestDetB[i] && TestDetC[i] != TestDetD[i])
return 1;
}
// shuffle test
glm::simdVec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::simdVec4 B(5.0f, 6.0f, 7.0f, 8.0f);
//__m128 C = _mm_shuffle_ps(A.Data, B.Data, _MM_SHUFFLE(1, 0, 1, 0));
Error += test_compute_glm();
Error += test_compute_gtx();
float Det = glm::determinant(glm::simdMat4(1.0));
Error += Det == 1.0f ? 0 : 1;
glm::simdMat4 D = glm::matrixCompMult(glm::simdMat4(1.0), glm::simdMat4(1.0));
return Error;
}
#else
int main()
{
int Error = 0;
return Error;
}
#endif//(GLM_ARCH != GLM_ARCH_PURE)
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_matrix_transform_2d.cpp | .cpp | 1,694 | 40 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_matrix_transform_2d.cpp
/// @date 2014-02-21 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/matrix_transform_2d.hpp>
int main()
{
int Error(0);
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtx/gtx_simd_vec4.cpp | .cpp | 2,524 | 72 | ///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/gtx/gtx_simd_vec4.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/simd_vec4.hpp>
#include <cstdio>
#if(GLM_ARCH != GLM_ARCH_PURE)
int main()
{
glm::simdVec4 A1(0.0f, 0.1f, 0.2f, 0.3f);
glm::simdVec4 B1(0.4f, 0.5f, 0.6f, 0.7f);
glm::simdVec4 C1 = A1 + B1;
glm::simdVec4 D1 = A1.swizzle<glm::X, glm::Z, glm::Y, glm::W>();
glm::simdVec4 E1(glm::vec4(1.0f));
glm::vec4 F1 = glm::vec4_cast(E1);
//glm::vec4 G1(E1);
//printf("A1(%2.3f, %2.3f, %2.3f, %2.3f)\n", A1.x, A1.y, A1.z, A1.w);
//printf("B1(%2.3f, %2.3f, %2.3f, %2.3f)\n", B1.x, B1.y, B1.z, B1.w);
//printf("C1(%2.3f, %2.3f, %2.3f, %2.3f)\n", C1.x, C1.y, C1.z, C1.w);
//printf("D1(%2.3f, %2.3f, %2.3f, %2.3f)\n", D1.x, D1.y, D1.z, D1.w);
__m128 value = _mm_set1_ps(0.0f);
__m128 data = _mm_cmpeq_ps(value, value);
__m128 add0 = _mm_add_ps(data, data);
glm::simdVec4 GNI(add0);
return 0;
}
#else
int main()
{
int Error = 0;
return Error;
}
#endif//(GLM_ARCH != GLM_ARCH_PURE)
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gli.hpp | .hpp | 1,001 | 32 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2010-09-29
// Licence : This source is under MIT License
// File : gli/gli.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
/*! \mainpage OpenGL Image
*
*/
#ifndef GLI_GLI_INCLUDED
#define GLI_GLI_INCLUDED
#define GLI_VERSION 31
#define GLI_VERSION_MAJOR 0
#define GLI_VERSION_MINOR 3
#define GLI_VERSION_PATCH 1
#define GLI_VERSION_REVISION 0
#include "./core/texture2d.hpp"
#include "./core/texture2d_array.hpp"
#include "./core/texture_cube.hpp"
#include "./core/texture_cube_array.hpp"
#include "./core/size.hpp"
#include "./core/operation.hpp"
#include "./core/generate_mipmaps.hpp"
#endif//GLI_GLI_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/wavelet.hpp | .hpp | 781 | 28 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-01-09
// Updated : 2010-01-09
// Licence : This source is under MIT License
// File : gli/gtx/wavelet.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_WAVELET_INCLUDED
#define GLI_GTX_WAVELET_INCLUDED
namespace gli{
namespace gtx{
namespace wavelet
{
}//namespace wavelet
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::wavelet;}
#include "wavelet.inl"
#endif//GLI_GTX_WAVELET_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/compression.hpp | .hpp | 813 | 28 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2010-01-09
// Licence : This source is under MIT License
// File : gli/gtx/compression.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_COMPRESSION_INCLUDED
#define GLI_GTX_COMPRESSION_INCLUDED
namespace gli{
namespace gtx{
namespace compression
{
}//namespace compression
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::compression;}
#include "compression.inl"
#endif//GLI_GTX_COMPRESSION_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/gl_texture2d.hpp | .hpp | 1,041 | 34 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-27
// Updated : 2010-10-01
// Licence : This source is under MIT License
// File : gli/gtx/gl_texture2d.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_GL_TEXTURE2D_INCLUDED
#define GLI_GTX_GL_TEXTURE2D_INCLUDED
#include "../gli.hpp"
#include "../gtx/loader.hpp"
#ifndef GL_VERSION_1_1
#error "ERROR: OpenGL must be included before GLI_GTX_gl_texture2d"
#endif//GL_VERSION_1_1
namespace gli{
namespace gtx{
namespace gl_texture2d
{
GLuint createTexture2D(std::string const & Filename);
}//namespace gl_texture2d
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::gl_texture2d;}
#include "gl_texture2d.inl"
#endif//GLI_GTX_GL_TEXTURE2D_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/loader.hpp | .hpp | 1,035 | 38 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_INCLUDED
#define GLI_GTX_LOADER_INCLUDED
#include "../gli.hpp"
#include "../gtx/loader_dds9.hpp"
#include "../gtx/loader_dds10.hpp"
#include "../gtx/loader_tga.hpp"
namespace gli{
namespace gtx{
namespace loader
{
inline texture2D load(
std::string const & Filename);
inline void save(
texture2D const & Image,
std::string const & Filename);
}//namespace loader
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader;}
#include "loader.inl"
#endif//GLI_GTX_LOADER_INCLUDED
| Unknown |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.