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/glm/test/external/gli/gtx/loader_tga.hpp | .hpp | 994 | 37 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// 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_tga.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_TGA_INCLUDED
#define GLI_GTX_LOADER_TGA_INCLUDED
#include "../gli.hpp"
#include <string>
#include <fstream>
namespace gli{
namespace gtx{
namespace loader_tga
{
texture2D loadTGA(
std::string const & Filename);
void saveTGA(
texture2D const & Image,
std::string const & Filename);
}//namespace loader_tga
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader_tga;}
#include "loader_tga.inl"
#endif//GLI_GTX_LOADER_TGA_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/loader_dds9.hpp | .hpp | 1,081 | 40 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// 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_dds9.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_DDS9_INCLUDED
#define GLI_GTX_LOADER_DDS9_INCLUDED
#include "../gli.hpp"
#include <fstream>
namespace gli{
namespace gtx{
namespace loader_dds9
{
texture2D loadDDS9(
std::string const & Filename);
void saveDDS9(
texture2D const & Texture,
std::string const & Filename);
void saveTextureCubeDDS9(
textureCube const & Texture,
std::string const & Filename);
}//namespace loader_dds9
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader_dds9;}
#include "loader_dds9.inl"
#endif//GLI_GTX_LOADER_DDS9_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/fetch.hpp | .hpp | 1,303 | 47 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/fetch.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_FETCH_INCLUDED
#define GLI_GTX_FETCH_INCLUDED
#include "../gli.hpp"
namespace gli{
namespace gtx{
namespace fetch
{
template <typename genType>
genType texelFetch(
texture2D const & Texture,
texture2D::dimensions_type const & Texcoord,
texture2D::level_type const & Level);
template <typename genType>
genType textureLod(
texture2D const & Texture,
texture2D::texcoord_type const & Texcoord,
texture2D::level_type const & Level);
template <typename genType>
void texelWrite(
texture2D & Texture,
texture2D::dimensions_type const & Texcoord,
texture2D::level_type const & Level,
genType const & Color);
}//namespace fetch
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::fetch;}
#include "fetch.inl"
#endif//GLI_GTX_FETCH_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/gradient.hpp | .hpp | 1,136 | 39 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gradient.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_GRADIENT_INCLUDED
#define GLI_GTX_GRADIENT_INCLUDED
#include "../gli.hpp"
namespace gli{
namespace gtx{
namespace gradient
{
texture2D radial(
texture2D::dimensions_type const & Size,
texture2D::texcoord_type const & Center,
float const & Radius,
texture2D::texcoord_type const & Focal);
texture2D linear(
texture2D::dimensions_type const & Size,
texture2D::texcoord_type const & Point0,
texture2D::texcoord_type const & Point1);
}//namespace gradient
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::gradient;}
#include "gradient.inl"
#endif//GLI_GTX_GRADIENT_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/gtx/loader_dds10.hpp | .hpp | 996 | 36 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-26
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_dds10.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_DDS10_INCLUDED
#define GLI_GTX_LOADER_DDS10_INCLUDED
#include "../gli.hpp"
#include <fstream>
namespace gli{
namespace gtx{
namespace loader_dds10
{
texture2D loadDDS10(
std::string const & Filename);
void saveDDS10(
texture2D const & Image,
std::string const & Filename);
}//namespace loader_dds10
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader_dds10;}
#include "loader_dds10.inl"
#endif//GLI_GTX_LOADER_DDS10_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/shared_ptr.hpp | .hpp | 1,260 | 42 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2005-06-13
// Licence : This source is under MIT License
// File : gli/fetch.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_SHARED_PTR_INCLUDED
#define GLI_SHARED_PTR_INCLUDED
namespace gli
{
template <typename T>
class shared_ptr
{
public:
shared_ptr();
shared_ptr(shared_ptr const & SmartPtr);
shared_ptr(T* pPointer);
~shared_ptr();
T& operator*();
T* operator->();
const T& operator*() const;
const T* operator->() const;
shared_ptr& operator=(shared_ptr const & SmartPtr);
shared_ptr& operator=(T* pPointer);
bool operator==(shared_ptr const & SmartPtr) const;
bool operator!=(shared_ptr const & SmartPtr) const;
private:
int* m_pReference;
T* m_pPointer;
};
}//namespace gli
#include "shared_ptr.inl"
#endif //GLI_SHARED_PTR_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/shared_array.hpp | .hpp | 1,361 | 49 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2005-06-13
// Licence : This source is under MIT License
// File : gli/shared_array.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_SHARED_ARRAY_INCLUDED
#define GLI_SHARED_ARRAY_INCLUDED
namespace gli
{
template <typename T>
class shared_array
{
public:
shared_array();
shared_array(shared_array const & SharedArray);
shared_array(T * Pointer);
virtual ~shared_array();
void reset();
void reset(T * Pointer);
T & operator*();
T * operator->();
T const & operator*() const;
T const * const operator->() const;
T * get();
T const * const get() const;
shared_array & operator=(shared_array const & SharedArray);
bool operator==(shared_array const & SharedArray) const;
bool operator!=(shared_array const & SharedArray) const;
private:
int * Counter;
T * Pointer;
};
}//namespace gli
#include "shared_array.inl"
#endif //GLI_SHARED_ARRAY_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/generate_mipmaps.hpp | .hpp | 824 | 26 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-27
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/core/generate_mipmaps.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GENERATE_MIPMAPS_INCLUDED
#define GLI_GENERATE_MIPMAPS_INCLUDED
#include "texture2d.hpp"
namespace gli
{
texture2D generateMipmaps(
texture2D const & Texture,
texture2D::level_type const & BaseLevel);
}//namespace gli
#include "generate_mipmaps.inl"
#endif//GLI_GENERATE_MIPMAPS_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/size.hpp | .hpp | 936 | 32 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-08
// Licence : This source is under MIT License
// File : gli/core/size.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_SIZE_INCLUDED
#define GLI_CORE_SIZE_INCLUDED
#include "texture2d.hpp"
namespace gli
{
//template <size_type sizeType>
image2D::size_type size(
image2D const & Image,
image2D::size_type const & SizeType);
//template <size_type sizeType>
texture2D::size_type size(
texture2D const & Texture,
texture2D::size_type const & SizeType);
}//namespace gli
#include "size.inl"
#endif//GLI_CORE_SIZE_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/texture_cube_array.hpp | .hpp | 1,669 | 60 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube_array.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
#define GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
#include "texture_cube.hpp"
namespace gli
{
class textureCubeArray
{
public:
typedef textureCube::dimensions_type dimensions_type;
typedef textureCube::texcoord_type texcoord_type;
typedef textureCube::size_type size_type;
typedef textureCube::value_type value_type;
typedef textureCube::format_type format_type;
typedef std::vector<textureCube> data_type;
typedef textureCube::level_type level_type;
typedef data_type::size_type layer_type;
public:
textureCubeArray();
explicit textureCubeArray(
layer_type const & Layers,
level_type const & Levels);
~textureCubeArray();
textureCube & operator[] (
layer_type const & Layer);
textureCube const & operator[] (
layer_type const & Layer) const;
bool empty() const;
format_type format() const;
layer_type layers() const;
level_type levels() const;
void resize(
layer_type const & Layers,
level_type const & Levels);
private:
data_type Arrays;
};
}//namespace gli
#include "texture_cube_array.inl"
#endif//GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/image2d.hpp | .hpp | 2,858 | 170 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-05
// Updated : 2011-04-05
// Licence : This source is under MIT License
// File : gli/core/image2d.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_IMAGE2D_INCLUDED
#define GLI_CORE_IMAGE2D_INCLUDED
// STD
#include <vector>
#include <cassert>
#include <cmath>
#include <cstring>
// GLM
#include <glm/glm.hpp>
#include <glm/gtx/number_precision.hpp>
#include <glm/gtx/raw_data.hpp>
#include <glm/gtx/gradient_paint.hpp>
#include <glm/gtx/component_wise.hpp>
namespace gli
{
enum format
{
FORMAT_NULL,
// Unsigned integer formats
R8U,
RG8U,
RGB8U,
RGBA8U,
R16U,
RG16U,
RGB16U,
RGBA16U,
R32U,
RG32U,
RGB32U,
RGBA32U,
// Signed integer formats
R8I,
RG8I,
RGB8I,
RGBA8I,
R16I,
RG16I,
RGB16I,
RGBA16I,
R32I,
RG32I,
RGB32I,
RGBA32I,
// Floating formats
R16F,
RG16F,
RGB16F,
RGBA16F,
R32F,
RG32F,
RGB32F,
RGBA32F,
// Packed formats
RGBE8,
RGB9E5,
RG11B10F,
R5G6B5,
RGBA4,
RGB10A2,
// Depth formats
D16,
D24X8,
D24S8,
D32F,
D32FS8X24,
// Compressed formats
DXT1,
DXT3,
DXT5,
ATI1N_UNORM,
ATI1N_SNORM,
ATI2N_UNORM,
ATI2N_SNORM,
BP_UF16,
BP_SF16,
BP,
FORMAT_MAX
};
enum size_type
{
LINEAR_SIZE,
BLOCK_SIZE,
BIT_PER_PIXEL,
COMPONENT
};
class image2D
{
public:
typedef glm::uvec2 dimensions_type;
typedef glm::vec2 texcoord_type;
typedef glm::uint32 size_type;
typedef glm::byte value_type;
typedef gli::format format_type;
typedef std::vector<value_type> data_type;
public:
image2D();
image2D(
image2D const & Image);
explicit image2D(
dimensions_type const & Dimensions,
format_type const & Format);
template <typename genType>
explicit image2D(
dimensions_type const & Dimensions,
format_type const & Format,
genType const & Value);
explicit image2D(
dimensions_type const & Dimensions,
format_type const & Format,
std::vector<value_type> const & Data);
~image2D();
template <typename genType>
void setPixel(
dimensions_type const & TexelCoord,
genType const & TexelData);
size_type value_size() const;
size_type capacity() const;
dimensions_type dimensions() const;
size_type components() const;
format_type format() const;
value_type * data();
value_type const * const data() const;
private:
data_type Data;
dimensions_type Dimensions;
format_type Format;
};
}//namespace gli
#include "image2d.inl"
#endif//GLI_CORE_IMAGE2D_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/operator.hpp | .hpp | 878 | 29 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-01-19
// Updated : 2010-01-19
// Licence : This source is under MIT License
// File : gli/core/operator.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_OPERATOR_INCLUDED
#define GLI_OPERATOR_INCLUDED
#include "texture2d.hpp"
namespace gli{
namespace detail
{
}//namespace detail
texture2D operator+(texture2D const & TextureA, texture2D const & TextureB);
texture2D operator-(texture2D const & TextureA, texture2D const & TextureB);
}//namespace gli
#include "operator.inl"
#endif//GLI_OPERATOR_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/dummy.cpp | .cpp | 16 | 5 | int main()
{
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/operation.hpp | .hpp | 2,172 | 83 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/operation.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_OPERATION_INCLUDED
#define GLI_OPERATION_INCLUDED
#include "texture2d.hpp"
namespace gli
{
texture2D duplicate(texture2D const & Texture);
texture2D flip(texture2D const & Texture);
texture2D mirror(texture2D const & Texture);
texture2D swizzle(
texture2D const & Texture,
glm::uvec4 const & Channel);
texture2D crop(
texture2D const & Texture,
texture2D::dimensions_type const & Position,
texture2D::dimensions_type const & Size);
image2D crop(
image2D const & Image,
texture2D::dimensions_type const & Position,
texture2D::dimensions_type const & Size);
image2D copy(
image2D const & SrcImage,
image2D::dimensions_type const & SrcPosition,
image2D::dimensions_type const & SrcSize,
image2D & DstImage,
image2D::dimensions_type const & DstPosition);
//image operator+(image const & MipmapA, image const & MipmapB);
//image operator-(image const & MipmapA, image const & MipmapB);
//image operator*(image const & MipmapA, image const & MipmapB);
//image operator/(image const & MipmapA, image const & MipmapB);
//namespace wip
//{
// template <typename GENTYPE, template <typename> class SURFACE>
// GENTYPE fetch(SURFACE<GENTYPE> const & Image)
// {
// return GENTYPE();
// }
// template
// <
// typename GENTYPE,
// template
// <
// typename
// >
// class SURFACE,
// template
// <
// typename,
// template
// <
// typename
// >
// class
// >
// class IMAGE
// >
// GENTYPE fetch(IMAGE<GENTYPE, SURFACE> const & Image)
// {
// return GENTYPE();
// }
//}//namespace wip
}//namespace gli
#include "operation.inl"
#endif//GLI_OPERATION_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/texture2d.hpp | .hpp | 2,629 | 123 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/core/texture2d.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE2D_INCLUDED
#define GLI_CORE_TEXTURE2D_INCLUDED
#include "image2d.hpp"
namespace gli
{
enum comp
{
X = 0,
R = 0,
S = 0,
Y = 1,
G = 1,
T = 1,
Z = 2,
B = 2,
P = 2,
W = 3,
A = 3,
Q = 3
};
//template <template <typename> class mem>
class texture2D
{
public:
typedef image2D::dimensions_type dimensions_type;
typedef image2D::texcoord_type texcoord_type;
typedef image2D::size_type size_type;
typedef image2D::value_type value_type;
typedef image2D::format_type format_type;
typedef image2D::data_type data_type;
typedef std::size_t level_type;
public:
texture2D();
explicit texture2D(level_type const & Levels);
//texture2D(image const & Mipmap, bool GenerateMipmaps = false);
~texture2D();
image2D & operator[] (
level_type const & Level);
image2D const & operator[] (
level_type const & Level) const;
bool empty() const;
format_type format() const;
level_type levels() const;
void resize(level_type const & Levels);
template <typename genType>
void swizzle(gli::comp X, gli::comp Y, gli::comp Z, gli::comp W);
private:
std::vector<image2D> Images;
};
//namespace wip
//{
// // plain
// template <typename genType>
// class plain
// {
// public:
//
// private:
// boost::shared_array<genType> Data;
// };
//
// // texture2D
// template
// <
// typename genType,
// template <typename> class surface = plain
// >
// class texture2D
// {
// public:
// typedef genType value_type;
//
// private:
// class image_impl
// {
// public:
// template <typename coordType>
// value_type const & operator() (coordType const & Coord) const;
//
// private:
// surface<value_type> Surface;
// };
//
// public:
// typedef image_impl image;
// typedef std::vector<image> mipmaps;
// typedef typename mipmaps::size_type level_type;
//
// level_type levels() const;
// image & operator[] (level_type Level);
// image const & operator[] (level_type Level) const;
//
// private:
// mipmaps Mipmaps;
// };
//
//}//namespace wip
}//namespace gli
#include "texture2d.inl"
#endif//GLI_CORE_TEXTURE2D_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/texture_cube.hpp | .hpp | 1,602 | 66 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE_CUBE_INCLUDED
#define GLI_CORE_TEXTURE_CUBE_INCLUDED
#include "texture2d.hpp"
namespace gli
{
enum face
{
POSITIVE_X,
NEGATIVE_X,
POSITIVE_Y,
NEGATIVE_Y,
POSITIVE_Z,
NEGATIVE_Z,
FACE_MAX
};
class textureCube
{
public:
typedef texture2D::dimensions_type dimensions_type;
typedef texture2D::texcoord_type texcoord_type;
typedef texture2D::size_type size_type;
typedef texture2D::value_type value_type;
typedef texture2D::format_type format_type;
typedef texture2D::data_type data_type;
typedef texture2D::level_type level_type;
typedef face face_type;
public:
textureCube();
explicit textureCube(level_type const & Levels);
~textureCube();
texture2D & operator[] (
face_type const & Face);
texture2D const & operator[] (
face_type const & Face) const;
bool empty() const;
format_type format() const;
level_type levels() const;
void resize(level_type const & Levels);
private:
std::vector<texture2D> Faces;
};
}//namespace gli
#include "texture_cube.inl"
#endif//GLI_CORE_TEXTURE_CUBE_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/external/gli/core/texture2d_array.hpp | .hpp | 1,649 | 60 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture2d_array.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
#define GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
#include "texture2d.hpp"
namespace gli
{
class texture2DArray
{
public:
typedef texture2D::dimensions_type dimensions_type;
typedef texture2D::texcoord_type texcoord_type;
typedef texture2D::size_type size_type;
typedef texture2D::value_type value_type;
typedef texture2D::format_type format_type;
typedef texture2D::data_type data_type;
typedef texture2D::level_type level_type;
typedef std::vector<texture2D>::size_type layer_type;
public:
texture2DArray();
explicit texture2DArray(
layer_type const & Layers,
level_type const & Levels);
~texture2DArray();
texture2D & operator[] (
layer_type const & Layer);
texture2D const & operator[] (
layer_type const & Layer) const;
bool empty() const;
format_type format() const;
layer_type layers() const;
level_type levels() const;
void resize(
layer_type const & Layers,
level_type const & Levels);
private:
std::vector<texture2D> Arrays;
};
}//namespace gli
#include "texture2d_array.inl"
#endif//GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_integer.cpp | .cpp | 41,557 | 1,590 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_integer.cpp
/// @date 2011-01-15 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/integer.hpp>
#include <glm/vector_relational.hpp>
#include <glm/gtc/vec1.hpp>
#include <vector>
#include <ctime>
#include <cstdio>
enum result
{
SUCCESS,
FAIL,
ASSERT,
STATIC_ASSERT
};
namespace bitfieldInsert
{
template <typename genType, typename sizeType>
struct type
{
genType Base;
genType Insert;
sizeType Offset;
sizeType Bits;
genType Return;
};
typedef type<glm::uint, glm::uint> typeU32;
typeU32 const Data32[] =
{
{0x00000000, 0xffffffff, 0, 32, 0xffffffff},
{0x00000000, 0xffffffff, 0, 31, 0x7fffffff},
{0x00000000, 0xffffffff, 0, 0, 0x00000000},
{0xff000000, 0x0000ff00, 8, 8, 0xff00ff00},
{0xffff0000, 0x0000ffff, 16, 16, 0x00000000},
{0x0000ffff, 0xffff0000, 16, 16, 0xffffffff}
};
int test()
{
int Error = 0;
glm::uint count = sizeof(Data32) / sizeof(typeU32);
for(glm::uint i = 0; i < count; ++i)
{
glm::uint Return = glm::bitfieldInsert(
Data32[i].Base,
Data32[i].Insert,
Data32[i].Offset,
Data32[i].Bits);
Error += Data32[i].Return == Return ? 0 : 1;
}
return Error;
}
}//bitfieldInsert
namespace bitfieldExtract
{
template <typename genType, typename sizeType>
struct type
{
genType Value;
sizeType Offset;
sizeType Bits;
genType Return;
result Result;
};
typedef type<glm::uint, glm::uint> typeU32;
typeU32 const Data32[] =
{
{0xffffffff, 0,32, 0xffffffff, SUCCESS},
{0xffffffff, 8, 0, 0x00000000, SUCCESS},
{0x00000000, 0,32, 0x00000000, SUCCESS},
{0x0f0f0f0f, 0,32, 0x0f0f0f0f, SUCCESS},
{0x00000000, 8, 0, 0x00000000, SUCCESS},
{0x80000000,31, 1, 0x00000001, SUCCESS},
{0x7fffffff,31, 1, 0x00000000, SUCCESS},
{0x00000300, 8, 8, 0x00000003, SUCCESS},
{0x0000ff00, 8, 8, 0x000000ff, SUCCESS},
{0xfffffff0, 0, 5, 0x00000010, SUCCESS},
{0x000000ff, 1, 3, 0x00000007, SUCCESS},
{0x000000ff, 0, 3, 0x00000007, SUCCESS},
{0x00000000, 0, 2, 0x00000000, SUCCESS},
{0xffffffff, 0, 8, 0x000000ff, SUCCESS},
{0xffff0000,16,16, 0x0000ffff, SUCCESS},
{0xfffffff0, 0, 8, 0x00000000, FAIL},
{0xffffffff,16,16, 0x00000000, FAIL},
//{0xffffffff,32, 1, 0x00000000, ASSERT}, // Throw an assert
//{0xffffffff, 0,33, 0x00000000, ASSERT}, // Throw an assert
//{0xffffffff,16,16, 0x00000000, ASSERT}, // Throw an assert
};
int test()
{
int Error = 0;
glm::uint count = sizeof(Data32) / sizeof(typeU32);
for(glm::uint i = 0; i < count; ++i)
{
glm::uint Return = glm::bitfieldExtract(
Data32[i].Value,
Data32[i].Offset,
Data32[i].Bits);
bool Compare = Data32[i].Return == Return;
if(Data32[i].Result == SUCCESS && Compare)
continue;
else if(Data32[i].Result == FAIL && !Compare)
continue;
Error += 1;
}
return Error;
}
}//extractField
namespace bitfieldReverse
{
/*
GLM_FUNC_QUALIFIER unsigned int bitfieldReverseLoop(unsigned int v)
{
unsigned int Result(0);
unsigned int const BitSize = static_cast<unsigned int>(sizeof(unsigned int) * 8);
for(unsigned int i = 0; i < BitSize; ++i)
{
unsigned int const BitSet(v & (static_cast<unsigned int>(1) << i));
unsigned int const BitFirst(BitSet >> i);
Result |= BitFirst << (BitSize - 1 - i);
}
return Result;
}
GLM_FUNC_QUALIFIER glm::uint64_t bitfieldReverseLoop(glm::uint64_t v)
{
glm::uint64_t Result(0);
glm::uint64_t const BitSize = static_cast<glm::uint64_t>(sizeof(unsigned int) * 8);
for(glm::uint64_t i = 0; i < BitSize; ++i)
{
glm::uint64_t const BitSet(v & (static_cast<glm::uint64_t>(1) << i));
glm::uint64_t const BitFirst(BitSet >> i);
Result |= BitFirst << (BitSize - 1 - i);
}
return Result;
}
*/
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldReverseLoop(vecType<T, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldReverse' only accept integer values");
vecType<T, P> Result(0);
T const BitSize = static_cast<T>(sizeof(T) * 8);
for(T i = 0; i < BitSize; ++i)
{
vecType<T, P> const BitSet(v & (static_cast<T>(1) << i));
vecType<T, P> const BitFirst(BitSet >> i);
Result |= BitFirst << (BitSize - 1 - i);
}
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER T bitfieldReverseLoop(T v)
{
return bitfieldReverseLoop(glm::tvec1<T>(v)).x;
}
GLM_FUNC_QUALIFIER glm::uint32_t bitfieldReverseUint32(glm::uint32_t x)
{
x = (x & 0x55555555) << 1 | (x & 0xAAAAAAAA) >> 1;
x = (x & 0x33333333) << 2 | (x & 0xCCCCCCCC) >> 2;
x = (x & 0x0F0F0F0F) << 4 | (x & 0xF0F0F0F0) >> 4;
x = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8;
x = (x & 0x0000FFFF) << 16 | (x & 0xFFFF0000) >> 16;
return x;
}
GLM_FUNC_QUALIFIER glm::uint64_t bitfieldReverseUint64(glm::uint64_t x)
{
x = (x & 0x5555555555555555) << 1 | (x & 0xAAAAAAAAAAAAAAAA) >> 1;
x = (x & 0x3333333333333333) << 2 | (x & 0xCCCCCCCCCCCCCCCC) >> 2;
x = (x & 0x0F0F0F0F0F0F0F0F) << 4 | (x & 0xF0F0F0F0F0F0F0F0) >> 4;
x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
return x;
}
template <bool EXEC = false>
struct compute_bitfieldReverseStep
{
template <typename T, glm::precision P, template <class, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T, T)
{
return v;
}
};
template <>
struct compute_bitfieldReverseStep<true>
{
template <typename T, glm::precision P, template <class, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T Mask, T Shift)
{
return (v & Mask) << Shift | (v & (~Mask)) >> Shift;
}
};
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldReverseOps(vecType<T, P> const & v)
{
vecType<T, P> x(v);
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 2>::call(x, T(0x5555555555555555ull), static_cast<T>( 1));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 4>::call(x, T(0x3333333333333333ull), static_cast<T>( 2));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 8>::call(x, T(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 16>::call(x, T(0x00FF00FF00FF00FFull), static_cast<T>( 8));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 32>::call(x, T(0x0000FFFF0000FFFFull), static_cast<T>(16));
x = compute_bitfieldReverseStep<sizeof(T) * 8 >= 64>::call(x, T(0x00000000FFFFFFFFull), static_cast<T>(32));
return x;
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitfieldReverseOps(genType x)
{
return bitfieldReverseOps(glm::tvec1<genType, glm::defaultp>(x)).x;
}
template <typename genType>
struct type
{
genType Value;
genType Return;
result Result;
};
typedef type<glm::uint> typeU32;
typeU32 const Data32[] =
{
{0x00000001, 0x80000000, SUCCESS},
{0x0000000f, 0xf0000000, SUCCESS},
{0x000000ff, 0xff000000, SUCCESS},
{0xf0000000, 0x0000000f, SUCCESS},
{0xff000000, 0x000000ff, SUCCESS},
{0xffffffff, 0xffffffff, SUCCESS},
{0x00000000, 0x00000000, SUCCESS}
};
typedef type<glm::uint64> typeU64;
#if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC44))
typeU64 const Data64[] =
{
{0xf000000000000000LLU, 0x000000000000000fLLU, SUCCESS},
{0xffffffffffffffffLLU, 0xffffffffffffffffLLU, SUCCESS},
{0x0000000000000000LLU, 0x0000000000000000LLU, SUCCESS}
};
#else
typeU64 const Data64[] =
{
{0x00000000000000ff, 0xff00000000000000, SUCCESS},
{0x000000000000000f, 0xf000000000000000, SUCCESS},
{0xf000000000000000, 0x000000000000000f, SUCCESS},
{0xffffffffffffffff, 0xffffffffffffffff, SUCCESS},
{0x0000000000000000, 0x0000000000000000, SUCCESS}
};
#endif
int test32_bitfieldReverse()
{
int Error = 0;
std::size_t const Count = sizeof(Data32) / sizeof(typeU32);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint Return = glm::bitfieldReverse(Data32[i].Value);
bool Compare = Data32[i].Return == Return;
if(Data32[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test32_bitfieldReverseLoop()
{
int Error = 0;
std::size_t const Count = sizeof(Data32) / sizeof(typeU32);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint Return = bitfieldReverseLoop(Data32[i].Value);
bool Compare = Data32[i].Return == Return;
if(Data32[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test32_bitfieldReverseUint32()
{
int Error = 0;
std::size_t const Count = sizeof(Data32) / sizeof(typeU32);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint Return = bitfieldReverseUint32(Data32[i].Value);
bool Compare = Data32[i].Return == Return;
if(Data32[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test32_bitfieldReverseOps()
{
int Error = 0;
std::size_t const Count = sizeof(Data32) / sizeof(typeU32);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint Return = bitfieldReverseOps(Data32[i].Value);
bool Compare = Data32[i].Return == Return;
if(Data32[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test64_bitfieldReverse()
{
int Error = 0;
std::size_t const Count = sizeof(Data64) / sizeof(typeU64);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint64 Return = glm::bitfieldReverse(Data64[i].Value);
bool Compare = Data64[i].Return == Return;
if(Data64[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test64_bitfieldReverseLoop()
{
int Error = 0;
std::size_t const Count = sizeof(Data64) / sizeof(typeU64);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint64 Return = bitfieldReverseLoop(Data64[i].Value);
bool Compare = Data64[i].Return == Return;
if(Data32[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test64_bitfieldReverseUint64()
{
int Error = 0;
std::size_t const Count = sizeof(Data64) / sizeof(typeU64);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint64 Return = bitfieldReverseUint64(Data64[i].Value);
bool Compare = Data64[i].Return == Return;
if(Data64[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test64_bitfieldReverseOps()
{
int Error = 0;
std::size_t const Count = sizeof(Data64) / sizeof(typeU64);
for(std::size_t i = 0; i < Count; ++i)
{
glm::uint64 Return = bitfieldReverseOps(Data64[i].Value);
bool Compare = Data64[i].Return == Return;
if(Data64[i].Result == SUCCESS)
Error += Compare ? 0 : 1;
else
Error += Compare ? 1 : 0;
}
return Error;
}
int test()
{
int Error = 0;
Error += test32_bitfieldReverse();
Error += test32_bitfieldReverseLoop();
Error += test32_bitfieldReverseUint32();
Error += test32_bitfieldReverseOps();
Error += test64_bitfieldReverse();
Error += test64_bitfieldReverseLoop();
Error += test64_bitfieldReverseUint64();
Error += test64_bitfieldReverseOps();
return Error;
}
int perf32()
{
int Error = 0;
glm::uint32 Count = 10000000;
std::vector<glm::uint32> Data;
Data.resize(static_cast<std::size_t>(Count));
std::clock_t Timestamps0 = std::clock();
for(glm::uint32 k = 0; k < Count; ++k)
Data[k] = glm::bitfieldReverse(k);
std::clock_t Timestamps1 = std::clock();
for(glm::uint32 k = 0; k < Count; ++k)
Data[k] = bitfieldReverseLoop(k);
std::clock_t Timestamps2 = std::clock();
for(glm::uint32 k = 0; k < Count; ++k)
Data[k] = bitfieldReverseUint32(k);
std::clock_t Timestamps3 = std::clock();
for(glm::uint32 k = 0; k < Count; ++k)
Data[k] = bitfieldReverseOps(k);
std::clock_t Timestamps4 = std::clock();
std::printf("glm::bitfieldReverse: %d clocks\n", static_cast<unsigned int>(Timestamps1 - Timestamps0));
std::printf("bitfieldReverseLoop: %d clocks\n", static_cast<unsigned int>(Timestamps2 - Timestamps1));
std::printf("bitfieldReverseUint32: %d clocks\n", static_cast<unsigned int>(Timestamps3 - Timestamps2));
std::printf("bitfieldReverseOps: %d clocks\n", static_cast<unsigned int>(Timestamps4 - Timestamps3));
return Error;
}
int perf64()
{
int Error = 0;
glm::uint64 Count = 10000000;
std::vector<glm::uint64> Data;
Data.resize(static_cast<std::size_t>(Count));
std::clock_t Timestamps0 = std::clock();
for(glm::uint32 k = 0; k < Count; ++k)
Data[k] = glm::bitfieldReverse(k);
std::clock_t Timestamps1 = std::clock();
for(glm::uint64 k = 0; k < Count; ++k)
Data[k] = bitfieldReverseLoop(k);
std::clock_t Timestamps2 = std::clock();
for(glm::uint64 k = 0; k < Count; ++k)
Data[k] = bitfieldReverseUint64(k);
std::clock_t Timestamps3 = std::clock();
for(glm::uint64 k = 0; k < Count; ++k)
Data[k] = bitfieldReverseOps(k);
std::clock_t Timestamps4 = std::clock();
std::printf("glm::bitfieldReverse - 64: %d clocks\n", static_cast<unsigned int>(Timestamps1 - Timestamps0));
std::printf("bitfieldReverseLoop - 64: %d clocks\n", static_cast<unsigned int>(Timestamps2 - Timestamps1));
std::printf("bitfieldReverseUint - 64: %d clocks\n", static_cast<unsigned int>(Timestamps3 - Timestamps2));
std::printf("bitfieldReverseOps - 64: %d clocks\n", static_cast<unsigned int>(Timestamps4 - Timestamps3));
return Error;
}
int perf()
{
int Error = 0;
Error += perf32();
Error += perf64();
return Error;
}
}//bitfieldReverse
namespace findMSB
{
template <typename genType, typename retType>
struct type
{
genType Value;
retType Return;
};
# if GLM_HAS_BITSCAN_WINDOWS
template <typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_intrinsic(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
if(Value == 0)
return -1;
unsigned long Result(0);
_BitScanReverse(&Result, Value);
return int(Result);
}
# endif//GLM_HAS_BITSCAN_WINDOWS
# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC
template <typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_avx(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
if(Value == 0)
return -1;
return int(_tzcnt_u32(Value));
}
# endif//GLM_ARCH & GLM_ARCH_AVX && GLM_PLATFORM & GLM_PLATFORM_WINDOWS
template <typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_095(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
if(Value == genIUType(0) || Value == genIUType(-1))
return -1;
else if(Value > 0)
{
genIUType Bit = genIUType(-1);
for(genIUType tmp = Value; tmp > 0; tmp >>= 1, ++Bit){}
return Bit;
}
else //if(Value < 0)
{
int const BitCount(sizeof(genIUType) * 8);
int MostSignificantBit(-1);
for(int BitIndex(0); BitIndex < BitCount; ++BitIndex)
MostSignificantBit = (Value & (1 << BitIndex)) ? MostSignificantBit : BitIndex;
assert(MostSignificantBit >= 0);
return MostSignificantBit;
}
}
template <typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_nlz1(genIUType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findMSB' only accept integer values");
if (x == 0)
return -1;
int n = 0;
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;}
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;}
if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;}
if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;}
if (x <= 0x7FFFFFFF) {n = n + 1;}
return 31 - n;
}
int findMSB_nlz2(unsigned int x)
{
unsigned y;
int n;
n = 32;
y = x >>16; if (y != 0) {n = n -16; x = y;}
y = x >> 8; if (y != 0) {n = n - 8; x = y;}
y = x >> 4; if (y != 0) {n = n - 4; x = y;}
y = x >> 2; if (y != 0) {n = n - 2; x = y;}
y = x >> 1; if (y != 0) return n - 2;
return 32 - (n - x);
}
int findMSB_pop(unsigned int x)
{
x = x | (x >> 1);
x = x | (x >> 2);
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >>16);
return 31 - glm::bitCount(~x);
}
int perf_int()
{
type<int, int> const Data[] =
{
{0x00000000, -1},
{0x00000001, 0},
{0x00000002, 1},
{0x00000003, 1},
{0x00000004, 2},
{0x00000005, 2},
{0x00000007, 2},
{0x00000008, 3},
{0x00000010, 4},
{0x00000020, 5},
{0x00000040, 6},
{0x00000080, 7},
{0x00000100, 8},
{0x00000200, 9},
{0x00000400, 10},
{0x00000800, 11},
{0x00001000, 12},
{0x00002000, 13},
{0x00004000, 14},
{0x00008000, 15},
{0x00010000, 16},
{0x00020000, 17},
{0x00040000, 18},
{0x00080000, 19},
{0x00100000, 20},
{0x00200000, 21},
{0x00400000, 22},
{0x00800000, 23},
{0x01000000, 24},
{0x02000000, 25},
{0x04000000, 26},
{0x08000000, 27},
{0x10000000, 28},
{0x20000000, 29},
{0x40000000, 30}
};
int Error(0);
std::size_t const Count(10000000);
std::clock_t Timestamps0 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = glm::findMSB(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps1 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = findMSB_nlz1(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps2 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = findMSB_nlz2(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps3 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = findMSB_095(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps4 = std::clock();
# if GLM_HAS_BITSCAN_WINDOWS
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = findMSB_intrinsic(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
# endif//GLM_HAS_BITSCAN_WINDOWS
std::clock_t Timestamps5 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = findMSB_pop(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps6 = std::clock();
# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int, int>); ++i)
{
int Result = findMSB_avx(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
# endif
std::clock_t Timestamps7 = std::clock();
std::printf("glm::findMSB: %d clocks\n", static_cast<unsigned int>(Timestamps1 - Timestamps0));
std::printf("findMSB - nlz1: %d clocks\n", static_cast<unsigned int>(Timestamps2 - Timestamps1));
std::printf("findMSB - nlz2: %d clocks\n", static_cast<unsigned int>(Timestamps3 - Timestamps2));
std::printf("findMSB - 0.9.5: %d clocks\n", static_cast<unsigned int>(Timestamps4 - Timestamps3));
# if GLM_HAS_BITSCAN_WINDOWS
std::printf("findMSB - intrinsics: %d clocks\n", static_cast<unsigned int>(Timestamps5 - Timestamps4));
# endif//GLM_HAS_BITSCAN_WINDOWS
std::printf("findMSB - pop: %d clocks\n", static_cast<unsigned int>(Timestamps6 - Timestamps5));
# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC
std::printf("findMSB - avx tzcnt: %d clocks\n", static_cast<unsigned int>(Timestamps7 - Timestamps6));
# endif//GLM_ARCH & GLM_ARCH_AVX && GLM_PLATFORM & GLM_PLATFORM_WINDOWS
return Error;
}
int test_ivec4()
{
type<glm::ivec4, glm::ivec4> const Data[] =
{
{glm::ivec4(0x00000000), glm::ivec4(-1)},
{glm::ivec4(0x00000001), glm::ivec4( 0)},
{glm::ivec4(0x00000002), glm::ivec4( 1)},
{glm::ivec4(0x00000003), glm::ivec4( 1)},
{glm::ivec4(0x00000004), glm::ivec4( 2)},
{glm::ivec4(0x00000005), glm::ivec4( 2)},
{glm::ivec4(0x00000007), glm::ivec4( 2)},
{glm::ivec4(0x00000008), glm::ivec4( 3)},
{glm::ivec4(0x00000010), glm::ivec4( 4)},
{glm::ivec4(0x00000020), glm::ivec4( 5)},
{glm::ivec4(0x00000040), glm::ivec4( 6)},
{glm::ivec4(0x00000080), glm::ivec4( 7)},
{glm::ivec4(0x00000100), glm::ivec4( 8)},
{glm::ivec4(0x00000200), glm::ivec4( 9)},
{glm::ivec4(0x00000400), glm::ivec4(10)},
{glm::ivec4(0x00000800), glm::ivec4(11)},
{glm::ivec4(0x00001000), glm::ivec4(12)},
{glm::ivec4(0x00002000), glm::ivec4(13)},
{glm::ivec4(0x00004000), glm::ivec4(14)},
{glm::ivec4(0x00008000), glm::ivec4(15)},
{glm::ivec4(0x00010000), glm::ivec4(16)},
{glm::ivec4(0x00020000), glm::ivec4(17)},
{glm::ivec4(0x00040000), glm::ivec4(18)},
{glm::ivec4(0x00080000), glm::ivec4(19)},
{glm::ivec4(0x00100000), glm::ivec4(20)},
{glm::ivec4(0x00200000), glm::ivec4(21)},
{glm::ivec4(0x00400000), glm::ivec4(22)},
{glm::ivec4(0x00800000), glm::ivec4(23)},
{glm::ivec4(0x01000000), glm::ivec4(24)},
{glm::ivec4(0x02000000), glm::ivec4(25)},
{glm::ivec4(0x04000000), glm::ivec4(26)},
{glm::ivec4(0x08000000), glm::ivec4(27)},
{glm::ivec4(0x10000000), glm::ivec4(28)},
{glm::ivec4(0x20000000), glm::ivec4(29)},
{glm::ivec4(0x40000000), glm::ivec4(30)}
};
int Error(0);
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::ivec4, glm::ivec4>); ++i)
{
glm::ivec4 Result0 = glm::findMSB(Data[i].Value);
Error += glm::all(glm::equal(Data[i].Return, Result0)) ? 0 : 1;
}
return Error;
}
int test_int()
{
typedef type<glm::uint, int> entry;
entry const Data[] =
{
{0x00000000, -1},
{0x00000001, 0},
{0x00000002, 1},
{0x00000003, 1},
{0x00000004, 2},
{0x00000005, 2},
{0x00000007, 2},
{0x00000008, 3},
{0x00000010, 4},
{0x00000020, 5},
{0x00000040, 6},
{0x00000080, 7},
{0x00000100, 8},
{0x00000200, 9},
{0x00000400, 10},
{0x00000800, 11},
{0x00001000, 12},
{0x00002000, 13},
{0x00004000, 14},
{0x00008000, 15},
{0x00010000, 16},
{0x00020000, 17},
{0x00040000, 18},
{0x00080000, 19},
{0x00100000, 20},
{0x00200000, 21},
{0x00400000, 22},
{0x00800000, 23},
{0x01000000, 24},
{0x02000000, 25},
{0x04000000, 26},
{0x08000000, 27},
{0x10000000, 28},
{0x20000000, 29},
{0x40000000, 30}
};
int Error(0);
for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i)
{
int Result0 = glm::findMSB(Data[i].Value);
Error += Data[i].Return == Result0 ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i)
{
int Result0 = findMSB_nlz1(Data[i].Value);
Error += Data[i].Return == Result0 ? 0 : 1;
}
/*
for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i)
{
int Result0 = findMSB_nlz2(Data[i].Value);
Error += Data[i].Return == Result0 ? 0 : 1;
}
*/
for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i)
{
int Result0 = findMSB_095(Data[i].Value);
Error += Data[i].Return == Result0 ? 0 : 1;
}
# if GLM_HAS_BITSCAN_WINDOWS
for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i)
{
int Result0 = findMSB_intrinsic(Data[i].Value);
Error += Data[i].Return == Result0 ? 0 : 1;
}
# endif//GLM_HAS_BITSCAN_WINDOWS
for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i)
{
int Result0 = findMSB_pop(Data[i].Value);
Error += Data[i].Return == Result0 ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_ivec4();
Error += test_int();
return Error;
}
int perf()
{
int Error(0);
Error += perf_int();
return Error;
}
}//findMSB
namespace findLSB
{
template <typename genType, typename retType>
struct type
{
genType Value;
retType Return;
};
typedef type<int, int> entry;
entry const DataI32[] =
{
{0x00000001, 0},
{0x00000003, 0},
{0x00000002, 1},
// {0x80000000, 31}, // Clang generates an error with this
{0x00010000, 16},
{0x7FFF0000, 16},
{0x7F000000, 24},
{0x7F00FF00, 8},
{0x00000000, -1}
};
# if GLM_HAS_BITSCAN_WINDOWS
template <typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_intrinsic(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
if(Value == 0)
return -1;
unsigned long Result(0);
_BitScanForward(&Result, Value);
return int(Result);
}
# endif
template <typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_095(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
if(Value == 0)
return -1;
genIUType Bit;
for(Bit = genIUType(0); !(Value & (1 << Bit)); ++Bit){}
return Bit;
}
template <typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_ntz2(genIUType x)
{
if(x == 0)
return -1;
return glm::bitCount(~x & (x - static_cast<genIUType>(1)));
}
template <typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_branchfree(genIUType x)
{
bool IsNull(x == 0);
int const Keep(!IsNull);
int const Discard(IsNull);
return static_cast<int>(glm::bitCount(~x & (x - static_cast<genIUType>(1)))) * Keep + Discard * -1;
}
int test_int()
{
int Error(0);
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = glm::findLSB(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_095(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
# if GLM_HAS_BITSCAN_WINDOWS
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_intrinsic(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
# endif
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_ntz2(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_branchfree(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_int();
return Error;
}
int perf_int()
{
int Error(0);
std::size_t const Count(10000000);
std::clock_t Timestamps0 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = glm::findLSB(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps1 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_095(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps2 = std::clock();
# if GLM_HAS_BITSCAN_WINDOWS
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_intrinsic(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
# endif
std::clock_t Timestamps3 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_ntz2(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps4 = std::clock();
for(std::size_t k = 0; k < Count; ++k)
for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i)
{
int Result = findLSB_branchfree(DataI32[i].Value);
Error += DataI32[i].Return == Result ? 0 : 1;
}
std::clock_t Timestamps5 = std::clock();
std::printf("glm::findLSB: %d clocks\n", static_cast<unsigned int>(Timestamps1 - Timestamps0));
std::printf("findLSB - 0.9.5: %d clocks\n", static_cast<unsigned int>(Timestamps2 - Timestamps1));
# if GLM_HAS_BITSCAN_WINDOWS
std::printf("findLSB - intrinsics: %d clocks\n", static_cast<unsigned int>(Timestamps3 - Timestamps2));
# endif
std::printf("findLSB - ntz2: %d clocks\n", static_cast<unsigned int>(Timestamps4 - Timestamps3));
std::printf("findLSB - branchfree: %d clocks\n", static_cast<unsigned int>(Timestamps5 - Timestamps4));
return Error;
}
int perf()
{
int Error(0);
Error += perf_int();
return Error;
}
}//findLSB
namespace uaddCarry
{
int test()
{
int Error(0);
{
glm::uint x = std::numeric_limits<glm::uint>::max();
glm::uint y = 0;
glm::uint Carry = 0;
glm::uint Result = glm::uaddCarry(x, y, Carry);
Error += Carry == 0 ? 0 : 1;
Error += Result == std::numeric_limits<glm::uint>::max() ? 0 : 1;
}
{
glm::uint x = std::numeric_limits<glm::uint>::max();
glm::uint y = 1;
glm::uint Carry = 0;
glm::uint Result = glm::uaddCarry(x, y, Carry);
Error += Carry == 1 ? 0 : 1;
Error += Result == 0 ? 0 : 1;
}
{
glm::uvec1 x(std::numeric_limits<glm::uint>::max());
glm::uvec1 y(0);
glm::uvec1 Carry(0);
glm::uvec1 Result(glm::uaddCarry(x, y, Carry));
Error += glm::all(glm::equal(Carry, glm::uvec1(0))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec1(std::numeric_limits<glm::uint>::max()))) ? 0 : 1;
}
{
glm::uvec1 x(std::numeric_limits<glm::uint>::max());
glm::uvec1 y(1);
glm::uvec1 Carry(0);
glm::uvec1 Result(glm::uaddCarry(x, y, Carry));
Error += glm::all(glm::equal(Carry, glm::uvec1(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec1(0))) ? 0 : 1;
}
return Error;
}
}//namespace uaddCarry
namespace usubBorrow
{
int test()
{
int Error(0);
{
glm::uint x = 16;
glm::uint y = 17;
glm::uint Borrow = 0;
glm::uint Result = glm::usubBorrow(x, y, Borrow);
Error += Borrow == 1 ? 0 : 1;
Error += Result == 1 ? 0 : 1;
}
{
glm::uvec1 x(16);
glm::uvec1 y(17);
glm::uvec1 Borrow(0);
glm::uvec1 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec1(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec1(1))) ? 0 : 1;
}
{
glm::uvec2 x(16);
glm::uvec2 y(17);
glm::uvec2 Borrow(0);
glm::uvec2 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec2(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec2(1))) ? 0 : 1;
}
{
glm::uvec3 x(16);
glm::uvec3 y(17);
glm::uvec3 Borrow(0);
glm::uvec3 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec3(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec3(1))) ? 0 : 1;
}
{
glm::uvec4 x(16);
glm::uvec4 y(17);
glm::uvec4 Borrow(0);
glm::uvec4 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec4(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec4(1))) ? 0 : 1;
}
return Error;
}
}//namespace usubBorrow
namespace umulExtended
{
int test()
{
int Error(0);
{
glm::uint x = 2;
glm::uint y = 3;
glm::uint msb = 0;
glm::uint lsb = 0;
glm::umulExtended(x, y, msb, lsb);
Error += msb == 0 ? 0 : 1;
Error += lsb == 6 ? 0 : 1;
}
{
glm::uvec1 x(2);
glm::uvec1 y(3);
glm::uvec1 msb(0);
glm::uvec1 lsb(0);
glm::umulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::uvec1(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::uvec1(6))) ? 0 : 1;
}
{
glm::uvec2 x(2);
glm::uvec2 y(3);
glm::uvec2 msb(0);
glm::uvec2 lsb(0);
glm::umulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::uvec2(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::uvec2(6))) ? 0 : 1;
}
{
glm::uvec3 x(2);
glm::uvec3 y(3);
glm::uvec3 msb(0);
glm::uvec3 lsb(0);
glm::umulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::uvec3(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::uvec3(6))) ? 0 : 1;
}
{
glm::uvec4 x(2);
glm::uvec4 y(3);
glm::uvec4 msb(0);
glm::uvec4 lsb(0);
glm::umulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::uvec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::uvec4(6))) ? 0 : 1;
}
return Error;
}
}//namespace umulExtended
namespace imulExtended
{
int test()
{
int Error(0);
{
int x = 2;
int y = 3;
int msb = 0;
int lsb = 0;
glm::imulExtended(x, y, msb, lsb);
Error += msb == 0 ? 0 : 1;
Error += lsb == 6 ? 0 : 1;
}
{
glm::ivec1 x(2);
glm::ivec1 y(3);
glm::ivec1 msb(0);
glm::ivec1 lsb(0);
glm::imulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::ivec1(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::ivec1(6))) ? 0 : 1;
}
{
glm::ivec2 x(2);
glm::ivec2 y(3);
glm::ivec2 msb(0);
glm::ivec2 lsb(0);
glm::imulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::ivec2(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::ivec2(6))) ? 0 : 1;
}
{
glm::ivec3 x(2);
glm::ivec3 y(3);
glm::ivec3 msb(0);
glm::ivec3 lsb(0);
glm::imulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::ivec3(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::ivec3(6))) ? 0 : 1;
}
{
glm::ivec4 x(2);
glm::ivec4 y(3);
glm::ivec4 msb(0);
glm::ivec4 lsb(0);
glm::imulExtended(x, y, msb, lsb);
Error += glm::all(glm::equal(msb, glm::ivec4(0))) ? 0 : 1;
Error += glm::all(glm::equal(lsb, glm::ivec4(6))) ? 0 : 1;
}
return Error;
}
}//namespace imulExtended
namespace bitCount
{
template <typename genType>
struct type
{
genType Value;
genType Return;
};
type<int> const DataI32[] =
{
{0x00000001, 1},
{0x00000003, 2},
{0x00000002, 1},
{0x7fffffff, 31},
{0x00000000, 0}
};
template <typename T>
inline int bitCount_if(T v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitCount' only accept integer values");
int Count(0);
for(T i = 0, n = static_cast<T>(sizeof(T) * 8); i < n; ++i)
{
if(v & static_cast<T>(1 << i))
++Count;
}
return Count;
}
template <typename T>
inline int bitCount_vec(T v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitCount' only accept integer values");
int Count(0);
for(T i = 0, n = static_cast<T>(sizeof(T) * 8); i < n; ++i)
{
Count += static_cast<int>((v >> i) & static_cast<T>(1));
}
return Count;
}
template <bool EXEC = false>
struct compute_bitfieldBitCountStep
{
template <typename T, glm::precision P, template <class, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T, T)
{
return v;
}
};
template <>
struct compute_bitfieldBitCountStep<true>
{
template <typename T, glm::precision P, template <class, glm::precision> class vecType>
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & v, T Mask, T Shift)
{
return (v & Mask) + ((v >> Shift) & Mask);
}
};
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<int, P> bitCount_bitfield(vecType<T, P> const & v)
{
vecType<typename glm::detail::make_unsigned<T>::type, P> x(*reinterpret_cast<vecType<typename glm::detail::make_unsigned<T>::type, P> const *>(&v));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 2>::call(x, typename glm::detail::make_unsigned<T>::type(0x5555555555555555ull), typename glm::detail::make_unsigned<T>::type( 1));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 4>::call(x, typename glm::detail::make_unsigned<T>::type(0x3333333333333333ull), typename glm::detail::make_unsigned<T>::type( 2));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 8>::call(x, typename glm::detail::make_unsigned<T>::type(0x0F0F0F0F0F0F0F0Full), typename glm::detail::make_unsigned<T>::type( 4));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 16>::call(x, typename glm::detail::make_unsigned<T>::type(0x00FF00FF00FF00FFull), typename glm::detail::make_unsigned<T>::type( 8));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 32>::call(x, typename glm::detail::make_unsigned<T>::type(0x0000FFFF0000FFFFull), typename glm::detail::make_unsigned<T>::type(16));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 64>::call(x, typename glm::detail::make_unsigned<T>::type(0x00000000FFFFFFFFull), typename glm::detail::make_unsigned<T>::type(32));
return vecType<int, P>(x);
}
template <typename genType>
GLM_FUNC_QUALIFIER int bitCount_bitfield(genType x)
{
return bitCount_bitfield(glm::tvec1<genType, glm::defaultp>(x)).x;
}
int perf()
{
int Error(0);
std::size_t Size = 10000000;
std::vector<int> v;
v.resize(Size);
std::vector<glm::ivec4> w;
w.resize(Size);
std::clock_t TimestampsA = std::clock();
// bitCount - TimeIf
{
for(std::size_t i = 0, n = v.size(); i < n; ++i)
v[i] = bitCount_if(i);
}
std::clock_t TimestampsB = std::clock();
// bitCount - TimeVec
{
for(std::size_t i = 0, n = v.size(); i < n; ++i)
v[i] = bitCount_vec(i);
}
std::clock_t TimestampsC = std::clock();
// bitCount - TimeDefault
{
for(std::size_t i = 0, n = v.size(); i < n; ++i)
v[i] = glm::bitCount(i);
}
std::clock_t TimestampsD = std::clock();
// bitCount - TimeVec4
{
for(std::size_t i = 0, n = v.size(); i < n; ++i)
w[i] = glm::bitCount(glm::ivec4(static_cast<int>(i)));
}
std::clock_t TimestampsE = std::clock();
{
for(std::size_t i = 0, n = v.size(); i < n; ++i)
v[i] = bitCount_bitfield(static_cast<int>(i));
}
std::clock_t TimestampsF = std::clock();
std::printf("bitCount - TimeIf %d\n", static_cast<unsigned int>(TimestampsB - TimestampsA));
std::printf("bitCount - TimeVec %d\n", static_cast<unsigned int>(TimestampsC - TimestampsB));
std::printf("bitCount - TimeDefault %d\n", static_cast<unsigned int>(TimestampsD - TimestampsC));
std::printf("bitCount - TimeVec4 %d\n", static_cast<unsigned int>(TimestampsE - TimestampsD));
std::printf("bitCount - bitfield %d\n", static_cast<unsigned int>(TimestampsF - TimestampsE));
return Error;
}
int test()
{
int Error(0);
for(std::size_t i = 0, n = sizeof(DataI32) / sizeof(type<int>); i < n; ++i)
{
int ResultA = glm::bitCount(DataI32[i].Value);
int ResultB = bitCount_if(DataI32[i].Value);
int ResultC = bitCount_vec(DataI32[i].Value);
int ResultE = bitCount_bitfield(DataI32[i].Value);
Error += DataI32[i].Return == ResultA ? 0 : 1;
Error += DataI32[i].Return == ResultB ? 0 : 1;
Error += DataI32[i].Return == ResultC ? 0 : 1;
Error += DataI32[i].Return == ResultE ? 0 : 1;
assert(!Error);
}
return Error;
}
}//bitCount
int main()
{
int Error = 0;
Error += ::bitCount::test();
Error += ::bitfieldReverse::test();
Error += ::findMSB::test();
Error += ::findLSB::test();
Error += ::umulExtended::test();
Error += ::imulExtended::test();
Error += ::uaddCarry::test();
Error += ::usubBorrow::test();
Error += ::bitfieldInsert::test();
Error += ::bitfieldExtract::test();
# ifdef NDEBUG
Error += ::bitCount::perf();
Error += ::bitfieldReverse::perf();
Error += ::findMSB::perf();
Error += ::findLSB::perf();
# endif
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_vec2.cpp | .cpp | 7,736 | 338 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_vec2.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <vector>
#if GLM_HAS_TRIVIAL_QUERIES
# include <type_traits>
#endif
int test_vec2_operators()
{
int Error = 0;
{
glm::vec2 A(1.0f);
glm::vec2 B(1.0f);
Error += A != B ? 1 : 0;
Error += A == B ? 0 : 1;
}
{
glm::vec2 A(1.0f);
glm::vec2 C = A + 1.0f;
A += 1.0f;
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(1.0f);
glm::vec2 B(2.0f,-1.0f);
glm::vec2 C = A + B;
A += B;
Error += A.x == 3.0f && A.y == 0.0f ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(1.0f);
glm::vec2 C = A - 1.0f;
A -= 1.0f;
Error += A.x == 0.0f && A.y == 0.0f ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(1.0f);
glm::vec2 B(2.0f,-1.0f);
glm::vec2 C = A - B;
A -= B;
Error += A.x == -1.0f && A.y == 2.0f ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(1.0f);
glm::vec2 C = A * 2.0f;
A *= 2.0f;
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(2.0f);
glm::vec2 B(2.0f);
glm::vec2 C = A / B;
A /= B;
Error += A.x == 1.0f && A.y == 1.0f ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
glm::vec2 C = A + B;
Error += C == glm::vec2(5, 7) ? 0 : 1;
glm::vec2 D = B - A;
Error += D == glm::vec2(3, 3) ? 0 : 1;
glm::vec2 E = A * B;
Error += E == glm::vec2(4, 10) ? 0 : 1;
glm::vec2 F = B / A;
Error += F == glm::vec2(4, 2.5) ? 0 : 1;
glm::vec2 G = A + 1.0f;
Error += G == glm::vec2(2, 3) ? 0 : 1;
glm::vec2 H = B - 1.0f;
Error += H == glm::vec2(3, 4) ? 0 : 1;
glm::vec2 I = A * 2.0f;
Error += I == glm::vec2(2, 4) ? 0 : 1;
glm::vec2 J = B / 2.0f;
Error += J == glm::vec2(2, 2.5) ? 0 : 1;
glm::vec2 K = 1.0f + A;
Error += K == glm::vec2(2, 3) ? 0 : 1;
glm::vec2 L = 1.0f - B;
Error += L == glm::vec2(-3, -4) ? 0 : 1;
glm::vec2 M = 2.0f * A;
Error += M == glm::vec2(2, 4) ? 0 : 1;
glm::vec2 N = 2.0f / B;
Error += N == glm::vec2(0.5, 2.0 / 5.0) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
A += B;
Error += A == glm::vec2(5, 7) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec2(6, 8) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
B -= A;
Error += B == glm::vec2(3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec2(2, 2) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
A *= B;
Error += A == glm::vec2(4, 10) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec2(8, 20) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
B /= A;
Error += B == glm::vec2(4, 2.5) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec2(2, 1.25) ? 0 : 1;
}
{
glm::vec2 B(2.0f);
B /= B.y;
Error += B == glm::vec2(1.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = -A;
Error += B == glm::vec2(-1.0f, -2.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = --A;
Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = A--;
Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1;
Error += A == glm::vec2(0.0f, 1.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = ++A;
Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = A++;
Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1;
Error += A == glm::vec2(2.0f, 3.0f) ? 0 : 1;
}
return Error;
}
int test_vec2_ctor()
{
int Error = 0;
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::vec2>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::vec2>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::vec2>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dvec2>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::ivec2>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::uvec2>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::vec2>::value ? 0 : 1;
# endif
#if GLM_HAS_INITIALIZER_LISTS
{
glm::vec2 a{ 0, 1 };
std::vector<glm::vec2> v = {
{0, 1},
{4, 5},
{8, 9}};
}
{
glm::dvec2 a{ 0, 1 };
std::vector<glm::dvec2> v = {
{0, 1},
{4, 5},
{8, 9}};
}
#endif
#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
{
glm::vec2 A = glm::vec2(1.0f, 2.0f);
glm::vec2 B = A.xy;
glm::vec2 C(A.xy);
glm::vec2 D(A.xy());
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
}
#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
{
glm::vec2 A = glm::vec2(2.0f);
glm::vec2 B = glm::vec2(2.0f, 3.0f);
glm::vec2 C = glm::vec2(2.0f, 3.0);
//glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says?
glm::vec2 E(glm::dvec2(2.0));
glm::vec2 F(glm::ivec2(2));
}
return Error;
}
int test_vec2_size()
{
int Error = 0;
Error += sizeof(glm::vec2) == sizeof(glm::mediump_vec2) ? 0 : 1;
Error += 8 == sizeof(glm::mediump_vec2) ? 0 : 1;
Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1;
Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1;
Error += glm::vec2().length() == 2 ? 0 : 1;
Error += glm::dvec2().length() == 2 ? 0 : 1;
return Error;
}
int test_operator_increment()
{
int Error(0);
glm::ivec2 v0(1);
glm::ivec2 v1(v0);
glm::ivec2 v2(v0);
glm::ivec2 v3 = ++v1;
glm::ivec2 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
glm::vec2 v;
assert(v.length() == 2);
Error += test_vec2_size();
Error += test_vec2_ctor();
Error += test_vec2_operators();
Error += test_operator_increment();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_integer_find_lsb.cpp | .cpp | 12,875 | 432 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_integer_find_lsb.cpp
/// @date 2014-10-27 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
// This has the programs for computing the number of trailing zeros
// in a word.
// Max line length is 57, to fit in hacker.book.
#include <cstdio>
#include <cstdlib> //To define "exit", req'd by XLC.
#include <ctime>
int nlz(unsigned x) {
int pop(unsigned x);
x = x | (x >> 1);
x = x | (x >> 2);
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >>16);
return pop(~x);
}
int pop(unsigned x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0F0F0F0F;
x = x + (x << 8);
x = x + (x << 16);
return x >> 24;
}
int ntz1(unsigned x) {
return 32 - nlz(~x & (x-1));
}
int ntz2(unsigned x) {
return pop(~x & (x - 1));
}
int ntz3(unsigned x) {
int n;
if (x == 0) return(32);
n = 1;
if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;}
if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;}
if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;}
if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;}
return n - (x & 1);
}
int ntz4(unsigned x) {
unsigned y;
int n;
if (x == 0) return 32;
n = 31;
y = x <<16; if (y != 0) {n = n -16; x = y;}
y = x << 8; if (y != 0) {n = n - 8; x = y;}
y = x << 4; if (y != 0) {n = n - 4; x = y;}
y = x << 2; if (y != 0) {n = n - 2; x = y;}
y = x << 1; if (y != 0) {n = n - 1;}
return n;
}
int ntz4a(unsigned x) {
unsigned y;
int n;
if (x == 0) return 32;
n = 31;
y = x <<16; if (y != 0) {n = n -16; x = y;}
y = x << 8; if (y != 0) {n = n - 8; x = y;}
y = x << 4; if (y != 0) {n = n - 4; x = y;}
y = x << 2; if (y != 0) {n = n - 2; x = y;}
n = n - ((x << 1) >> 31);
return n;
}
int ntz5(char x)
{
if (x & 15) {
if (x & 3) {
if (x & 1) return 0;
else return 1;
}
else if (x & 4) return 2;
else return 3;
}
else if (x & 0x30) {
if (x & 0x10) return 4;
else return 5;
}
else if (x & 0x40) return 6;
else if (x) return 7;
else return 8;
}
int ntz6(unsigned x) {
int n;
x = ~x & (x - 1);
n = 0; // n = 32;
while(x != 0) { // while (x != 0) {
n = n + 1; // n = n - 1;
x = x >> 1; // x = x + x;
} // }
return n; // return n;
}
int ntz6a(unsigned x)
{
int n = 32;
while (x != 0) {
n = n - 1;
x = x + x;
}
return n;
}
/* Dean Gaudet's algorithm. To be most useful there must be a good way
to evaluate the C "conditional expression" (a?b:c construction) without
branching. The result of a?b:c is b if a is true (nonzero), and c if a
is false (0).
For example, a compare to zero op that sets a target GPR to 1 if the
operand is 0, and to 0 if the operand is nonzero, will do it. With this
instruction, the algorithm is entirely branch-free. But the most
interesting thing about it is the high degree of parallelism. All six
lines with conditional expressions can be executed in parallel (on a
machine with sufficient computational units).
Although the instruction count is 30 measured statically, it could
execute in only 10 cycles on a machine with sufficient parallelism.
The first two uses of y can instead be x, which would increase the
useful parallelism on most machines (the assignments to y, bz, and b4
could then all run in parallel). */
int ntz7(unsigned x)
{
unsigned y, bz, b4, b3, b2, b1, b0;
y = x & -x; // Isolate rightmost 1-bit.
bz = y ? 0 : 1; // 1 if y = 0.
b4 = (y & 0x0000FFFF) ? 0 : 16;
b3 = (y & 0x00FF00FF) ? 0 : 8;
b2 = (y & 0x0F0F0F0F) ? 0 : 4;
b1 = (y & 0x33333333) ? 0 : 2;
b0 = (y & 0x55555555) ? 0 : 1;
return bz + b4 + b3 + b2 + b1 + b0;
}
int ntz7_christophe(unsigned x)
{
unsigned y, bz, b4, b3, b2, b1, b0;
y = x & -x; // Isolate rightmost 1-bit.
bz = unsigned(!bool(y)); // 1 if y = 0.
b4 = unsigned(!bool(y & 0x0000FFFF)) * 16;
b3 = unsigned(!bool(y & 0x00FF00FF)) * 8;
b2 = unsigned(!bool(y & 0x0F0F0F0F)) * 4;
b1 = unsigned(!bool(y & 0x33333333)) * 2;
b0 = unsigned(!bool(y & 0x55555555)) * 1;
return bz + b4 + b3 + b2 + b1 + b0;
}
/* Below is David Seal's algorithm, found at
http://www.ciphersbyritter.com/NEWS4/BITCT.HTM Table
entries marked "u" are unused. 6 ops including a
multiply, plus an indexed load. */
#define u 99
int ntz8(unsigned x)
{
static char table[64] =
{32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14,
10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15,
31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26,
30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u};
x = (x & -x)*0x0450FBAF;
return table[x >> 26];
}
/* Seal's algorithm with multiply expanded.
9 elementary ops plus an indexed load. */
int ntz8a(unsigned x)
{
static char table[64] =
{32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14,
10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15,
31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26,
30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u};
x = (x & -x);
x = (x << 4) + x; // x = x*17.
x = (x << 6) + x; // x = x*65.
x = (x << 16) - x; // x = x*65535.
return table[x >> 26];
}
/* Reiser's algorithm. Three ops including a "remainder,"
plus an indexed load. */
int ntz9(unsigned x) {
static char table[37] = {32, 0, 1, 26, 2, 23, 27,
u, 3, 16, 24, 30, 28, 11, u, 13, 4,
7, 17, u, 25, 22, 31, 15, 29, 10, 12,
6, u, 21, 14, 9, 5, 20, 8, 19, 18};
x = (x & -x)%37;
return table[x];
}
/* Using a de Bruijn sequence. This is a table lookup with a 32-entry
table. The de Bruijn sequence used here is
0000 0100 1101 0111 0110 0101 0001 1111,
obtained from Danny Dube's October 3, 1997, posting in
comp.compression.research. Thanks to Norbert Juffa for this reference. */
int ntz10(unsigned x) {
static char table[32] =
{ 0, 1, 2,24, 3,19, 6,25, 22, 4,20,10,16, 7,12,26,
31,23,18, 5,21, 9,15,11, 30,17, 8,14,29,13,28,27};
if (x == 0) return 32;
x = (x & -x)*0x04D7651F;
return table[x >> 27];
}
/* Norbert Juffa's code, answer to exercise 1 of Chapter 5 (2nd ed). */
#define SLOW_MUL
int ntz11 (unsigned int n) {
static unsigned char tab[32] =
{ 0, 1, 2, 24, 3, 19, 6, 25,
22, 4, 20, 10, 16, 7, 12, 26,
31, 23, 18, 5, 21, 9, 15, 11,
30, 17, 8, 14, 29, 13, 28, 27
};
unsigned int k;
n = n & (-n); /* isolate lsb */
printf("n = %d\n", n);
#if defined(SLOW_MUL)
k = (n << 11) - n;
k = (k << 2) + k;
k = (k << 8) + n;
k = (k << 5) - k;
#else
k = n * 0x4d7651f;
#endif
return n ? tab[k>>27] : 32;
}
int errors;
void error(int x, int y) {
errors = errors + 1;
printf("Error for x = %08x, got %d\n", x, y);
}
/* ------------------------------ main ------------------------------ */
int main()
{
# ifdef NDEBUG
int i, m, n;
static unsigned test[] = {0,32, 1,0, 2,1, 3,0, 4,2, 5,0, 6,1, 7,0,
8,3, 9,0, 16,4, 32,5, 64,6, 128,7, 255,0, 256,8, 512,9, 1024,10,
2048,11, 4096,12, 8192,13, 16384,14, 32768,15, 65536,16,
0x20000,17, 0x40000,18, 0x80000,19, 0x100000,20, 0x200000,21,
0x400000,22, 0x800000,23, 0x1000000,24, 0x2000000,25,
0x4000000,26, 0x8000000,27, 0x10000000,28, 0x20000000,29,
0x40000000,30, 0x80000000,31, 0xFFFFFFF0,4, 0x3000FF00,8,
0xC0000000,30, 0x60000000,29, 0x00011000, 12};
std::size_t const Count = 10000000;
n = sizeof(test)/4;
std::clock_t TimestampBeg = 0;
std::clock_t TimestampEnd = 0;
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz1(test[i]) != test[i+1]) error(test[i], ntz1(test[i]));}
TimestampEnd = std::clock();
printf("ntz1: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz2(test[i]) != test[i+1]) error(test[i], ntz2(test[i]));}
TimestampEnd = std::clock();
printf("ntz2: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz3(test[i]) != test[i+1]) error(test[i], ntz3(test[i]));}
TimestampEnd = std::clock();
printf("ntz3: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz4(test[i]) != test[i+1]) error(test[i], ntz4(test[i]));}
TimestampEnd = std::clock();
printf("ntz4: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz4a(test[i]) != test[i+1]) error(test[i], ntz4a(test[i]));}
TimestampEnd = std::clock();
printf("ntz4a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
m = test[i+1]; if (m > 8) m = 8;
if (ntz5(test[i]) != m) error(test[i], ntz5(test[i]));}
TimestampEnd = std::clock();
printf("ntz5: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz6(test[i]) != test[i+1]) error(test[i], ntz6(test[i]));}
TimestampEnd = std::clock();
printf("ntz6: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz6a(test[i]) != test[i+1]) error(test[i], ntz6a(test[i]));}
TimestampEnd = std::clock();
printf("ntz6a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz7(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
TimestampEnd = std::clock();
printf("ntz7: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz7_christophe(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
TimestampEnd = std::clock();
printf("ntz7_christophe: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz8(test[i]) != test[i+1]) error(test[i], ntz8(test[i]));}
TimestampEnd = std::clock();
printf("ntz8: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz8a(test[i]) != test[i+1]) error(test[i], ntz8a(test[i]));}
TimestampEnd = std::clock();
printf("ntz8a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz9(test[i]) != test[i+1]) error(test[i], ntz9(test[i]));}
TimestampEnd = std::clock();
printf("ntz9: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz10(test[i]) != test[i+1]) error(test[i], ntz10(test[i]));}
TimestampEnd = std::clock();
printf("ntz10: %d clocks\n", TimestampEnd - TimestampBeg);
if (errors == 0)
printf("Passed all %d cases.\n", sizeof(test)/8);
# endif//NDEBUG
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_integer_bit_count.cpp | .cpp | 9,594 | 323 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_integer_bit_count.cpp
/// @date 2011-01-15 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
// This has the programs for computing the number of 1-bits
// in a word, or byte, etc.
// Max line length is 57, to fit in hacker.book.
#include <stdio.h>
#include <stdlib.h> //To define "exit", req'd by XLC.
#include <ctime>
unsigned rotatel(unsigned x, int n)
{
if ((unsigned)n > 63) {printf("rotatel, n out of range.\n"); exit(1);}
return (x << n) | (x >> (32 - n));
}
int pop0(unsigned x)
{
x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF);
x = (x & 0x0000FFFF) + ((x >>16) & 0x0000FFFF);
return x;
}
int pop1(unsigned x)
{
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0F0F0F0F;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x0000003F;
}
/* Note: an alternative to the last three executable lines above is:
return x*0x01010101 >> 24;
if your machine has a fast multiplier (suggested by Jari Kirma). */
int pop2(unsigned x)
{
unsigned n;
n = (x >> 1) & 033333333333; // Count bits in
x = x - n; // each 3-bit
n = (n >> 1) & 033333333333; // field.
x = x - n;
x = (x + (x >> 3)) & 030707070707; // 6-bit sums.
return x%63; // Add 6-bit sums.
}
/* An alternative to the "return" statement above is:
return ((x * 0404040404) >> 26) + // Add 6-bit sums.
(x >> 30);
which runs faster on most machines (suggested by Norbert Juffa). */
int pop3(unsigned x)
{
unsigned n;
n = (x >> 1) & 0x77777777; // Count bits in
x = x - n; // each 4-bit
n = (n >> 1) & 0x77777777; // field.
x = x - n;
n = (n >> 1) & 0x77777777;
x = x - n;
x = (x + (x >> 4)) & 0x0F0F0F0F; // Get byte sums.
x = x*0x01010101; // Add the bytes.
return x >> 24;
}
int pop4(unsigned x)
{
int n;
n = 0;
while (x != 0) {
n = n + 1;
x = x & (x - 1);
}
return n;
}
int pop5(unsigned x)
{
int i, sum;
// Rotate and sum method // Shift right & subtract
sum = x; // sum = x;
for (i = 1; i <= 31; i++) { // while (x != 0) {
x = rotatel(x, 1); // x = x >> 1;
sum = sum + x; // sum = sum - x;
} // }
return -sum; // return sum;
}
int pop5a(unsigned x)
{
int sum;
// Shift right & subtract
sum = x;
while (x != 0) {
x = x >> 1;
sum = sum - x;
}
return sum;
}
int pop6(unsigned x)
{ // Table lookup.
static char table[256] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
return table[x & 0xFF] +
table[(x >> 8) & 0xFF] +
table[(x >> 16) & 0xFF] +
table[(x >> 24)];
}
// The following works only for 8-bit quantities.
int pop7(unsigned x)
{
x = x*0x08040201; // Make 4 copies.
x = x >> 3; // So next step hits proper bits.
x = x & 0x11111111; // Every 4th bit.
x = x*0x11111111; // Sum the digits (each 0 or 1).
x = x >> 28; // Position the result.
return x;
}
// The following works only for 7-bit quantities.
int pop8(unsigned x)
{
x = x*0x02040810; // Make 4 copies, left-adjusted.
x = x & 0x11111111; // Every 4th bit.
x = x*0x11111111; // Sum the digits (each 0 or 1).
x = x >> 28; // Position the result.
return x;
}
// The following works only for 15-bit quantities.
int pop9(unsigned x)
{
unsigned long long y;
y = x * 0x0002000400080010ULL;
y = y & 0x1111111111111111ULL;
y = y * 0x1111111111111111ULL;
y = y >> 60;
return y;
}
int errors;
void error(int x, int y)
{
errors = errors + 1;
printf("Error for x = %08x, got %08x\n", x, y);
}
int main()
{
# ifdef NDEBUG
int i, n;
static int test[] = {0,0, 1,1, 2,1, 3,2, 4,1, 5,2, 6,2, 7,3,
8,1, 9,2, 10,2, 11,3, 12,2, 13,3, 14,3, 15,4, 16,1, 17,2,
0x3F,6, 0x40,1, 0x41,2, 0x7f,7, 0x80,1, 0x81,2, 0xfe,7, 0xff,8,
0x4000,1, 0x4001,2, 0x7000,3, 0x7fff,15,
0x55555555,16, 0xAAAAAAAA, 16, 0xFF000000,8, 0xC0C0C0C0,8,
0x0FFFFFF0,24, 0x80000000,1, 0xFFFFFFFF,32};
std::size_t const Count = 1000000;
n = sizeof(test)/4;
std::clock_t TimestampBeg = 0;
std::clock_t TimestampEnd = 0;
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop0(test[i]) != test[i+1]) error(test[i], pop0(test[i]));}
TimestampEnd = std::clock();
printf("pop0: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop1(test[i]) != test[i+1]) error(test[i], pop1(test[i]));}
TimestampEnd = std::clock();
printf("pop1: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop2(test[i]) != test[i+1]) error(test[i], pop2(test[i]));}
TimestampEnd = std::clock();
printf("pop2: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop3(test[i]) != test[i+1]) error(test[i], pop3(test[i]));}
TimestampEnd = std::clock();
printf("pop3: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop4(test[i]) != test[i+1]) error(test[i], pop4(test[i]));}
TimestampEnd = std::clock();
printf("pop4: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop5(test[i]) != test[i+1]) error(test[i], pop5(test[i]));}
TimestampEnd = std::clock();
printf("pop5: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop5a(test[i]) != test[i+1]) error(test[i], pop5a(test[i]));}
TimestampEnd = std::clock();
printf("pop5a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (pop6(test[i]) != test[i+1]) error(test[i], pop6(test[i]));}
TimestampEnd = std::clock();
printf("pop6: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if ((test[i] & 0xffffff00) == 0)
if (pop7(test[i]) != test[i+1]) error(test[i], pop7(test[i]));}
TimestampEnd = std::clock();
printf("pop7: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if ((test[i] & 0xffffff80) == 0)
if (pop8(test[i]) != test[i+1]) error(test[i], pop8(test[i]));}
TimestampEnd = std::clock();
printf("pop8: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if ((test[i] & 0xffff8000) == 0)
if (pop9(test[i]) != test[i+1]) error(test[i], pop9(test[i]));}
TimestampEnd = std::clock();
printf("pop9: %d clocks\n", TimestampEnd - TimestampBeg);
if (errors == 0)
printf("Passed all %d cases.\n", sizeof(test)/8);
# endif//NDEBUG
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_vector_relational.cpp | .cpp | 2,156 | 74 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_vector_relational.cpp
/// @date 2011-01-15 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/vector_relational.hpp>
#include <glm/gtc/vec1.hpp>
int test_not()
{
int Error(0);
{
glm::bvec1 v(false);
Error += glm::all(glm::not_(v)) ? 0 : 1;
}
{
glm::bvec2 v(false);
Error += glm::all(glm::not_(v)) ? 0 : 1;
}
{
glm::bvec3 v(false);
Error += glm::all(glm::not_(v)) ? 0 : 1;
}
{
glm::bvec4 v(false);
Error += glm::all(glm::not_(v)) ? 0 : 1;
}
return Error;
}
int main()
{
int Error(0);
Error += test_not();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_cast.cpp | .cpp | 4,567 | 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/core/core_type_cast.cpp
/// @date 2013-05-06 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <algorithm>
#include <vector>
#include <iterator>
struct my_vec2
{
operator glm::vec2() { return glm::vec2(x, y); }
float x, y;
};
int test_vec2_cast()
{
glm::vec2 A(1.0f, 2.0f);
glm::lowp_vec2 B(A);
glm::mediump_vec2 C(A);
glm::highp_vec2 D(A);
glm::vec2 E = static_cast<glm::vec2>(A);
glm::lowp_vec2 F = static_cast<glm::lowp_vec2>(A);
glm::mediump_vec2 G = static_cast<glm::mediump_vec2>(A);
glm::highp_vec2 H = static_cast<glm::highp_vec2>(A);
my_vec2 I;
glm::vec2 J = static_cast<glm::vec2>(I);
glm::vec2 K(7.8f);
int Error(0);
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
return Error;
}
int test_vec3_cast()
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::lowp_vec3 B(A);
glm::mediump_vec3 C(A);
glm::highp_vec3 D(A);
glm::vec3 E = static_cast<glm::vec3>(A);
glm::lowp_vec3 F = static_cast<glm::lowp_vec3>(A);
glm::mediump_vec3 G = static_cast<glm::mediump_vec3>(A);
glm::highp_vec3 H = static_cast<glm::highp_vec3>(A);
int Error(0);
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
return Error;
}
int test_vec4_cast()
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::lowp_vec4 B(A);
glm::mediump_vec4 C(A);
glm::highp_vec4 D(A);
glm::vec4 E = static_cast<glm::vec4>(A);
glm::lowp_vec4 F = static_cast<glm::lowp_vec4>(A);
glm::mediump_vec4 G = static_cast<glm::mediump_vec4>(A);
glm::highp_vec4 H = static_cast<glm::highp_vec4>(A);
int Error(0);
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
return Error;
}
int test_std_copy()
{
int Error = 0;
{
std::vector<int> High;
High.resize(64);
std::vector<int> Medium(High.size());
std::copy(High.begin(), High.end(), Medium.begin());
*Medium.begin() = *High.begin();
}
{
std::vector<glm::dvec4> High4;
High4.resize(64);
std::vector<glm::vec4> Medium4(High4.size());
std::copy(High4.begin(), High4.end(), Medium4.begin());
*Medium4.begin() = *High4.begin();
}
{
std::vector<glm::dvec3> High3;
High3.resize(64);
std::vector<glm::vec3> Medium3(High3.size());
std::copy(High3.begin(), High3.end(), Medium3.begin());
*Medium3.begin() = *High3.begin();
}
{
std::vector<glm::dvec2> High2;
High2.resize(64);
std::vector<glm::vec2> Medium2(High2.size());
std::copy(High2.begin(), High2.end(), Medium2.begin());
*Medium2.begin() = *High2.begin();
}
glm::dvec4 v1;
glm::vec4 v2;
v2 = v1;
return Error;
}
int main()
{
int Error = 0;
Error += test_std_copy();
Error += test_vec2_cast();
Error += test_vec3_cast();
Error += test_vec4_cast();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat4x2.cpp | .cpp | 2,879 | 115 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat4x2.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat4x2.hpp>
#include <vector>
static int test_operators()
{
glm::mat4x2 l(1.0f);
glm::mat4x2 m(1.0f);
glm::vec4 u(1.0f);
glm::vec2 v(1.0f);
float x = 1.0f;
glm::vec2 a = m * u;
glm::vec4 b = v * m;
glm::mat4x2 n = x / m;
glm::mat4x2 o = m / x;
glm::mat4x2 p = x * m;
glm::mat4x2 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_ctr()
{
int Error(0);
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat4x2 m0(
glm::vec2(0, 1),
glm::vec2(2, 3),
glm::vec2(4, 5),
glm::vec2(6, 7));
glm::mat4x2 m1{0, 1, 2, 3, 4, 5, 6, 7};
glm::mat4x2 m2{
{0, 1},
{2, 3},
{4, 5},
{6, 7}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat4x2> v1{
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 1, 2, 3, 4, 5, 6, 7}
};
std::vector<glm::mat4x2> v2{
{
{ 0, 1},
{ 4, 5},
{ 8, 9},
{ 12, 13}
},
{
{ 0, 1},
{ 4, 5},
{ 8, 9},
{ 12, 13}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_length_size.cpp | .cpp | 3,816 | 117 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_length_size.cpp
/// @date 2011-05-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_SIZE_FUNC
#include <glm/glm.hpp>
#include <glm/gtc/vec1.hpp>
int test_length_mat_non_squared()
{
int Error = 0;
Error += glm::mat2x3().size() == 2 ? 0 : 1;
Error += glm::mat2x4().size() == 2 ? 0 : 1;
Error += glm::mat3x2().size() == 3 ? 0 : 1;
Error += glm::mat3x4().size() == 3 ? 0 : 1;
Error += glm::mat4x2().size() == 4 ? 0 : 1;
Error += glm::mat4x3().size() == 4 ? 0 : 1;
Error += glm::dmat2x3().size() == 2 ? 0 : 1;
Error += glm::dmat2x4().size() == 2 ? 0 : 1;
Error += glm::dmat3x2().size() == 3 ? 0 : 1;
Error += glm::dmat3x4().size() == 3 ? 0 : 1;
Error += glm::dmat4x2().size() == 4 ? 0 : 1;
Error += glm::dmat4x3().size() == 4 ? 0 : 1;
return Error;
}
int test_length_mat()
{
int Error = 0;
Error += glm::mat2().size() == 2 ? 0 : 1;
Error += glm::mat3().size() == 3 ? 0 : 1;
Error += glm::mat4().size() == 4 ? 0 : 1;
Error += glm::mat2x2().size() == 2 ? 0 : 1;
Error += glm::mat3x3().size() == 3 ? 0 : 1;
Error += glm::mat4x4().size() == 4 ? 0 : 1;
Error += glm::dmat2().size() == 2 ? 0 : 1;
Error += glm::dmat3().size() == 3 ? 0 : 1;
Error += glm::dmat4().size() == 4 ? 0 : 1;
Error += glm::dmat2x2().size() == 2 ? 0 : 1;
Error += glm::dmat3x3().size() == 3 ? 0 : 1;
Error += glm::dmat4x4().size() == 4 ? 0 : 1;
return Error;
}
int test_length_vec()
{
int Error = 0;
Error += glm::vec1().size() == 1 ? 0 : 1;
Error += glm::vec2().size() == 2 ? 0 : 1;
Error += glm::vec3().size() == 3 ? 0 : 1;
Error += glm::vec4().size() == 4 ? 0 : 1;
Error += glm::ivec1().size() == 1 ? 0 : 1;
Error += glm::ivec2().size() == 2 ? 0 : 1;
Error += glm::ivec3().size() == 3 ? 0 : 1;
Error += glm::ivec4().size() == 4 ? 0 : 1;
Error += glm::uvec1().size() == 1 ? 0 : 1;
Error += glm::uvec2().size() == 2 ? 0 : 1;
Error += glm::uvec3().size() == 3 ? 0 : 1;
Error += glm::uvec4().size() == 4 ? 0 : 1;
Error += glm::dvec1().size() == 1 ? 0 : 1;
Error += glm::dvec2().size() == 2 ? 0 : 1;
Error += glm::dvec3().size() == 3 ? 0 : 1;
Error += glm::dvec4().size() == 4 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_length_vec();
Error += test_length_mat();
Error += test_length_mat_non_squared();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat4x4.cpp | .cpp | 9,463 | 291 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat4x4.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/mat4x4.hpp>
#include <cstdio>
#include <vector>
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 test_inverse_mat4x4()
{
glm::mat4 Mat0(
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::mat4 Inv0 = glm::inverse(Mat0);
glm::mat4 Res0 = Mat0 * Inv0;
print(Mat0);
print(Inv0);
print(Res0);
return 0;
}
int test_inverse_dmat4x4()
{
glm::dmat4 Mat0(
glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::dvec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::dvec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::dvec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::dmat4 Inv0 = glm::inverse(Mat0);
glm::dmat4 Res0 = Mat0 * Inv0;
print(Mat0);
print(Inv0);
print(Res0);
return 0;
}
static bool test_operators()
{
glm::mat4x4 l(1.0f);
glm::mat4x4 m(1.0f);
glm::vec4 u(1.0f);
glm::vec4 v(1.0f);
float x = 1.0f;
glm::vec4 a = m * u;
glm::vec4 b = v * m;
glm::mat4x4 n = x / m;
glm::mat4x4 o = m / x;
glm::mat4x4 p = x * m;
glm::mat4x4 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_inverse()
{
int Error(0);
{
glm::mat4 const Matrix(
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::mat4 const Inverse = glm::inverse(Matrix);
glm::mat4 const Identity = Matrix * Inverse;
print(Matrix);
print(Inverse);
print(Identity);
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
}
{
glm::highp_mat4 const Matrix(
glm::highp_vec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::highp_vec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::highp_vec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::highp_vec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::highp_mat4 const Inverse = glm::inverse(Matrix);
glm::highp_mat4 const Identity = Matrix * Inverse;
printf("highp_mat4 inverse\n");
print(Matrix);
print(Inverse);
print(Identity);
Error += glm::all(glm::epsilonEqual(Identity[0], glm::highp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::highp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::highp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[3], glm::highp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
}
{
glm::mediump_mat4 const Matrix(
glm::mediump_vec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::mediump_vec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::mediump_vec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::mediump_vec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::mediump_mat4 const Inverse = glm::inverse(Matrix);
glm::mediump_mat4 const Identity = Matrix * Inverse;
printf("mediump_mat4 inverse\n");
print(Matrix);
print(Inverse);
print(Identity);
Error += glm::all(glm::epsilonEqual(Identity[0], glm::mediump_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::mediump_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::mediump_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[3], glm::mediump_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
}
{
glm::lowp_mat4 const Matrix(
glm::lowp_vec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::lowp_vec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::lowp_vec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::lowp_vec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::lowp_mat4 const Inverse = glm::inverse(Matrix);
glm::lowp_mat4 const Identity = Matrix * Inverse;
printf("lowp_mat4 inverse\n");
print(Matrix);
print(Inverse);
print(Identity);
Error += glm::all(glm::epsilonEqual(Identity[0], glm::lowp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::lowp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::lowp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[3], glm::lowp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
}
{
glm::mat4 const Matrix(
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
glm::mat4 const Identity = Matrix / Matrix;
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
}
return Error;
}
int test_ctr()
{
int Error(0);
#if GLM_HAS_TRIVIAL_QUERIES
//Error += std::is_trivially_default_constructible<glm::mat4>::value ? 0 : 1;
//Error += std::is_trivially_copy_assignable<glm::mat4>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::mat4>::value ? 0 : 1;
//Error += std::is_copy_constructible<glm::mat4>::value ? 0 : 1;
//Error += std::has_trivial_copy_constructor<glm::mat4>::value ? 0 : 1;
#endif
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat4 m0(
glm::vec4(0, 1, 2, 3),
glm::vec4(4, 5, 6, 7),
glm::vec4(8, 9, 10, 11),
glm::vec4(12, 13, 14, 15));
assert(sizeof(m0) == 4 * 4 * 4);
glm::vec4 V{0, 1, 2, 3};
glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
glm::mat4 m2{
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11},
{12, 13, 14, 15}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat4> m3{
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
std::vector<glm::mat4> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
std::vector<glm::mat4> v2{
{
{ 0, 1, 2, 3 },
{ 4, 5, 6, 7 },
{ 8, 9, 10, 11 },
{ 12, 13, 14, 15 }
},
{
{ 0, 1, 2, 3 },
{ 4, 5, 6, 7 },
{ 8, 9, 10, 11 },
{ 12, 13, 14, 15 }
}};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int perf_mul()
{
int Error = 0;
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_inverse_dmat4x4();
Error += test_inverse_mat4x4();
Error += test_operators();
Error += test_inverse();
Error += perf_mul();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_length.cpp | .cpp | 3,656 | 111 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_length.cpp
/// @date 2011-05-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
int test_length_mat_non_squared()
{
int Error = 0;
Error += glm::mat2x3().length() == 2 ? 0 : 1;
Error += glm::mat2x4().length() == 2 ? 0 : 1;
Error += glm::mat3x2().length() == 3 ? 0 : 1;
Error += glm::mat3x4().length() == 3 ? 0 : 1;
Error += glm::mat4x2().length() == 4 ? 0 : 1;
Error += glm::mat4x3().length() == 4 ? 0 : 1;
Error += glm::dmat2x3().length() == 2 ? 0 : 1;
Error += glm::dmat2x4().length() == 2 ? 0 : 1;
Error += glm::dmat3x2().length() == 3 ? 0 : 1;
Error += glm::dmat3x4().length() == 3 ? 0 : 1;
Error += glm::dmat4x2().length() == 4 ? 0 : 1;
Error += glm::dmat4x3().length() == 4 ? 0 : 1;
return Error;
}
int test_length_mat()
{
int Error = 0;
Error += glm::mat2().length() == 2 ? 0 : 1;
Error += glm::mat3().length() == 3 ? 0 : 1;
Error += glm::mat4().length() == 4 ? 0 : 1;
Error += glm::mat2x2().length() == 2 ? 0 : 1;
Error += glm::mat3x3().length() == 3 ? 0 : 1;
Error += glm::mat4x4().length() == 4 ? 0 : 1;
Error += glm::dmat2().length() == 2 ? 0 : 1;
Error += glm::dmat3().length() == 3 ? 0 : 1;
Error += glm::dmat4().length() == 4 ? 0 : 1;
Error += glm::dmat2x2().length() == 2 ? 0 : 1;
Error += glm::dmat3x3().length() == 3 ? 0 : 1;
Error += glm::dmat4x4().length() == 4 ? 0 : 1;
return Error;
}
int test_length_vec()
{
int Error = 0;
Error += glm::vec2().length() == 2 ? 0 : 1;
Error += glm::vec3().length() == 3 ? 0 : 1;
Error += glm::vec4().length() == 4 ? 0 : 1;
Error += glm::ivec2().length() == 2 ? 0 : 1;
Error += glm::ivec3().length() == 3 ? 0 : 1;
Error += glm::ivec4().length() == 4 ? 0 : 1;
Error += glm::uvec2().length() == 2 ? 0 : 1;
Error += glm::uvec3().length() == 3 ? 0 : 1;
Error += glm::uvec4().length() == 4 ? 0 : 1;
Error += glm::dvec2().length() == 2 ? 0 : 1;
Error += glm::dvec3().length() == 3 ? 0 : 1;
Error += glm::dvec4().length() == 4 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_length_vec();
Error += test_length_mat();
Error += test_length_mat_non_squared();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_setup_message.cpp | .cpp | 5,210 | 246 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-05-31
// Updated : 2013-08-27
// Licence : This source is under MIT License
// File : test/core/setup_message.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_MESSAGES
#include <glm/vec3.hpp>
#include <cstdio>
int test_compiler()
{
int Error(0);
if(GLM_COMPILER & GLM_COMPILER_VC)
{
switch(GLM_COMPILER)
{
case GLM_COMPILER_VC2010:
std::printf("GLM_COMPILER_VC2010\n");
break;
case GLM_COMPILER_VC2012:
std::printf("GLM_COMPILER_VC2012\n");
break;
case GLM_COMPILER_VC2013:
std::printf("GLM_COMPILER_VC2013\n");
break;
case GLM_COMPILER_VC2015:
std::printf("GLM_COMPILER_VC2015\n");
break;
default:
std::printf("Visual C++ version not detected\n");
Error += 1;
break;
}
}
else if(GLM_COMPILER & GLM_COMPILER_GCC)
{
switch(GLM_COMPILER)
{
case GLM_COMPILER_GCC44:
std::printf("GLM_COMPILER_GCC44\n");
break;
case GLM_COMPILER_GCC45:
std::printf("GLM_COMPILER_GCC45\n");
break;
case GLM_COMPILER_GCC46:
std::printf("GLM_COMPILER_GCC46\n");
break;
case GLM_COMPILER_GCC47:
std::printf("GLM_COMPILER_GCC47\n");
break;
case GLM_COMPILER_GCC48:
std::printf("GLM_COMPILER_GCC48\n");
break;
case GLM_COMPILER_GCC49:
std::printf("GLM_COMPILER_GCC49\n");
break;
case GLM_COMPILER_GCC50:
std::printf("GLM_COMPILER_GCC50\n");
break;
default:
std::printf("GCC version not detected\n");
Error += 1;
break;
}
}
else if(GLM_COMPILER & GLM_COMPILER_CUDA)
{
std::printf("GLM_COMPILER_CUDA\n");
}
else if(GLM_COMPILER & GLM_COMPILER_APPLE_CLANG)
{
switch(GLM_COMPILER)
{
case GLM_COMPILER_APPLE_CLANG40:
std::printf("GLM_COMPILER_APPLE_CLANG40\n");
break;
case GLM_COMPILER_APPLE_CLANG41:
std::printf("GLM_COMPILER_APPLE_CLANG41\n");
break;
case GLM_COMPILER_APPLE_CLANG42:
std::printf("GLM_COMPILER_APPLE_CLANG42\n");
break;
case GLM_COMPILER_APPLE_CLANG50:
std::printf("GLM_COMPILER_APPLE_CLANG50\n");
break;
case GLM_COMPILER_APPLE_CLANG51:
std::printf("GLM_COMPILER_APPLE_CLANG51\n");
break;
case GLM_COMPILER_APPLE_CLANG60:
std::printf("GLM_COMPILER_APPLE_CLANG60\n");
break;
default:
std::printf("Apple Clang version not detected\n");
break;
}
}
else if(GLM_COMPILER & GLM_COMPILER_LLVM)
{
switch(GLM_COMPILER)
{
case GLM_COMPILER_LLVM32:
std::printf("GLM_COMPILER_LLVM32\n");
break;
case GLM_COMPILER_LLVM33:
std::printf("GLM_COMPILER_LLVM33\n");
break;
case GLM_COMPILER_LLVM34:
std::printf("GLM_COMPILER_LLVM34\n");
break;
case GLM_COMPILER_LLVM35:
std::printf("GLM_COMPILER_LLVM35\n");
break;
default:
std::printf("LLVM version not detected\n");
break;
}
}
else if(GLM_COMPILER & GLM_COMPILER_INTEL)
{
switch(GLM_COMPILER)
{
case GLM_COMPILER_INTEL12:
std::printf("GLM_COMPILER_INTEL12\n");
break;
case GLM_COMPILER_INTEL12_1:
std::printf("GLM_COMPILER_INTEL12_1\n");
break;
case GLM_COMPILER_INTEL13:
std::printf("GLM_COMPILER_INTEL13\n");
break;
case GLM_COMPILER_INTEL14:
std::printf("GLM_COMPILER_INTEL14\n");
break;
case GLM_COMPILER_INTEL15:
std::printf("GLM_COMPILER_INTEL15\n");
break;
default:
std::printf("Intel compiler version not detected\n");
Error += 1;
break;
}
}
else
{
std::printf("Undetected compiler\n");
Error += 1;
}
return Error;
}
int test_model()
{
int Error = 0;
Error += ((sizeof(void*) == 4) && (GLM_MODEL == GLM_MODEL_32)) || ((sizeof(void*) == 8) && (GLM_MODEL == GLM_MODEL_64)) ? 0 : 1;
if(GLM_MODEL == GLM_MODEL_32)
std::printf("GLM_MODEL_32\n");
else if(GLM_MODEL == GLM_MODEL_64)
std::printf("GLM_MODEL_64\n");
return Error;
}
int test_instruction_set()
{
int Error = 0;
std::printf("GLM_ARCH: ");
if(GLM_ARCH == GLM_ARCH_PURE)
std::printf("GLM_ARCH_PURE ");
if(GLM_ARCH & GLM_ARCH_ARM)
std::printf("GLM_ARCH_ARM ");
if(GLM_ARCH & GLM_ARCH_AVX2)
std::printf("GLM_ARCH_AVX2 ");
if(GLM_ARCH & GLM_ARCH_AVX)
std::printf("GLM_ARCH_AVX ");
if(GLM_ARCH & GLM_ARCH_AVX)
std::printf("GLM_ARCH_SSE4 ");
if(GLM_ARCH & GLM_ARCH_SSE3)
std::printf("GLM_ARCH_SSE3 ");
if(GLM_ARCH & GLM_ARCH_SSE2)
std::printf("GLM_ARCH_SSE2 ");
std::printf("\n");
return Error;
}
int test_cpp_version()
{
std::printf("__cplusplus: %d\n", __cplusplus);
return 0;
}
int test_operators()
{
glm::vec3 A(1.0f);
glm::vec3 B(1.0f);
bool R = A != B;
bool S = A == B;
return (S && !R) ? 0 : 1;
}
template <typename T>
struct vec
{
};
template <template <typename> class C, typename T>
struct Class
{
};
template <typename T>
struct Class<vec, T>
{
};
int main()
{
//Class<vec, float> C;
int Error = 0;
Error += test_cpp_version();
Error += test_compiler();
Error += test_model();
Error += test_instruction_set();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_integer_find_msb.cpp | .cpp | 14,590 | 469 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_integer_find_msb.cpp
/// @date 2014-10-27 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
// This has the programs for computing the number of leading zeros
// in a word.
// Max line length is 57, to fit in hacker.book.
// Compile with g++, not gcc.
#include <cstdio>
#include <cstdlib> // To define "exit", req'd by XLC.
#include <ctime>
#define LE 1 // 1 for little-endian, 0 for big-endian.
int pop(unsigned x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0F0F0F0F;
x = x + (x << 8);
x = x + (x << 16);
return x >> 24;
}
int nlz1(unsigned x) {
int n;
if (x == 0) return(32);
n = 0;
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;}
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;}
if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;}
if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;}
if (x <= 0x7FFFFFFF) {n = n + 1;}
return n;
}
int nlz1a(unsigned x) {
int n;
/* if (x == 0) return(32); */
if ((int)x <= 0) return (~x >> 26) & 32;
n = 1;
if ((x >> 16) == 0) {n = n +16; x = x <<16;}
if ((x >> 24) == 0) {n = n + 8; x = x << 8;}
if ((x >> 28) == 0) {n = n + 4; x = x << 4;}
if ((x >> 30) == 0) {n = n + 2; x = x << 2;}
n = n - (x >> 31);
return n;
}
// On basic Risc, 12 to 20 instructions.
int nlz2(unsigned x) {
unsigned y;
int n;
n = 32;
y = x >>16; if (y != 0) {n = n -16; x = y;}
y = x >> 8; if (y != 0) {n = n - 8; x = y;}
y = x >> 4; if (y != 0) {n = n - 4; x = y;}
y = x >> 2; if (y != 0) {n = n - 2; x = y;}
y = x >> 1; if (y != 0) return n - 2;
return n - x;
}
// As above but coded as a loop for compactness:
// 23 to 33 basic Risc instructions.
int nlz2a(unsigned x) {
unsigned y;
int n, c;
n = 32;
c = 16;
do {
y = x >> c; if (y != 0) {n = n - c; x = y;}
c = c >> 1;
} while (c != 0);
return n - x;
}
int nlz3(int x) {
int y, n;
n = 0;
y = x;
L: if (x < 0) return n;
if (y == 0) return 32 - n;
n = n + 1;
x = x << 1;
y = y >> 1;
goto L;
}
int nlz4(unsigned x) {
int y, m, n;
y = -(x >> 16); // If left half of x is 0,
m = (y >> 16) & 16; // set n = 16. If left half
n = 16 - m; // is nonzero, set n = 0 and
x = x >> m; // shift x right 16.
// Now x is of the form 0000xxxx.
y = x - 0x100; // If positions 8-15 are 0,
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
n = n + m;
x = x << m;
y = x - 0x1000; // If positions 12-15 are 0,
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
n = n + m;
x = x << m;
y = x - 0x4000; // If positions 14-15 are 0,
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
n = n + m;
x = x << m;
y = x >> 14; // Set y = 0, 1, 2, or 3.
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
return n + 2 - m;
}
int nlz5(unsigned x) {
int pop(unsigned x);
x = x | (x >> 1);
x = x | (x >> 2);
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >>16);
return pop(~x);
}
/* The four programs below are not valid ANSI C programs. This is
because they refer to the same storage locations as two different types.
However, they work with xlc/AIX, gcc/AIX, and gcc/NT. If you try to
code them more compactly by declaring a variable xx to be "double," and
then using
n = 1054 - (*((unsigned *)&xx + LE) >> 20);
then you are violating not only the rule above, but also the ANSI C
rule that pointer arithmetic can be performed only on pointers to
array elements.
When coded with the above statement, the program fails with xlc,
gcc/AIX, and gcc/NT, at some optimization levels.
BTW, these programs use the "anonymous union" feature of C++, not
available in C. */
int nlz6(unsigned k) {
union {
unsigned asInt[2];
double asDouble;
};
int n;
asDouble = (double)k + 0.5;
n = 1054 - (asInt[LE] >> 20);
return n;
}
int nlz7(unsigned k) {
union {
unsigned asInt[2];
double asDouble;
};
int n;
asDouble = (double)k;
n = 1054 - (asInt[LE] >> 20);
n = (n & 31) + (n >> 9);
return n;
}
/* In single precision, round-to-nearest mode, the basic method fails for:
k = 0, k = 01FFFFFF, 03FFFFFE <= k <= 03FFFFFF,
07FFFFFC <= k <= 07FFFFFF,
0FFFFFF8 <= k <= 0FFFFFFF,
...
7FFFFFC0 <= k <= 7FFFFFFF.
FFFFFF80 <= k <= FFFFFFFF.
For k = 0 it gives 158, and for the other values it is too low by 1. */
int nlz8(unsigned k) {
union {
unsigned asInt;
float asFloat;
};
int n;
k = k & ~(k >> 1); /* Fix problem with rounding. */
asFloat = (float)k + 0.5f;
n = 158 - (asInt >> 23);
return n;
}
/* The example below shows how to make a macro for nlz. It uses an
extension to the C and C++ languages that is provided by the GNU C/C++
compiler, namely, that of allowing statements and declarations in
expressions (see "Using and Porting GNU CC", by Richard M. Stallman
(1998). The underscores are necessary to protect against the
possibility that the macro argument will conflict with one of its local
variables, e.g., NLZ(k). */
int nlz9(unsigned k) {
union {
unsigned asInt;
float asFloat;
};
int n;
k = k & ~(k >> 1); /* Fix problem with rounding. */
asFloat = (float)k;
n = 158 - (asInt >> 23);
n = (n & 31) + (n >> 6); /* Fix problem with k = 0. */
return n;
}
/* Below are three nearly equivalent programs for computing the number
of leading zeros in a word. This material is not in HD, but may be in a
future edition.
Immediately below is Robert Harley's algorithm, found at the
comp.arch newsgroup entry dated 7/12/96, pointed out to me by Norbert
Juffa.
Table entries marked "u" are unused. 14 ops including a multiply,
plus an indexed load.
The smallest multiplier that works is 0x045BCED1 = 17*65*129*513 (all
of form 2**k + 1). There are no multipliers of three terms of the form
2**k +- 1 that work, with a table size of 64 or 128. There are some,
with a table size of 64, if you precede the multiplication with x = x -
(x >> 1), but that seems less elegant. There are also some if you use a
table size of 256, the smallest is 0x01033CBF = 65*255*1025 (this would
save two instructions in the form of this algorithm with the
multiplication expanded into shifts and adds, but the table size is
getting a bit large). */
#define u 99
int nlz10(unsigned x) {
static char table[64] =
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
17, u, 4, u, u, u,11, u, 13,22,20, u,26, u, u,18,
5, u, u,23, u,27, u, 6, u,24, 7, u, 8, u, 0, u};
x = x | (x >> 1); // Propagate leftmost
x = x | (x >> 2); // 1-bit to the right.
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >>16);
x = x*0x06EB14F9; // Multiplier is 7*255**3.
return table[x >> 26];
}
/* Harley's algorithm with multiply expanded.
19 elementary ops plus an indexed load. */
int nlz10a(unsigned x) {
static char table[64] =
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
17, u, 4, u, u, u,11, u, 13,22,20, u,26, u, u,18,
5, u, u,23, u,27, u, 6, u,24, 7, u, 8, u, 0, u};
x = x | (x >> 1); // Propagate leftmost
x = x | (x >> 2); // 1-bit to the right.
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >> 16);
x = (x << 3) - x; // Multiply by 7.
x = (x << 8) - x; // Multiply by 255.
x = (x << 8) - x; // Again.
x = (x << 8) - x; // Again.
return table[x >> 26];
}
/* Julius Goryavsky's version of Harley's algorithm.
17 elementary ops plus an indexed load, if the machine
has "and not." */
int nlz10b(unsigned x) {
static char table[64] =
{32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u,
u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u,
u,21, u, 8,11, u,15, u, u, u, u, 2,27, 0,25, u,
22, u,12, u, u, 3,28, u, 23, u, 4,29, u, u,30,31};
x = x | (x >> 1); // Propagate leftmost
x = x | (x >> 2); // 1-bit to the right.
x = x | (x >> 4);
x = x | (x >> 8);
x = x & ~(x >> 16);
x = x*0xFD7049FF; // Activate this line or the following 3.
// x = (x << 9) - x; // Multiply by 511.
// x = (x << 11) - x; // Multiply by 2047.
// x = (x << 14) - x; // Multiply by 16383.
return table[x >> 26];
}
int errors;
void error(int x, int y) {
errors = errors + 1;
printf("Error for x = %08x, got %d\n", x, y);
}
int main()
{
# ifdef NDEBUG
int i, n;
static unsigned test[] = {0,32, 1,31, 2,30, 3,30, 4,29, 5,29, 6,29,
7,29, 8,28, 9,28, 16,27, 32,26, 64,25, 128,24, 255,24, 256,23,
512,22, 1024,21, 2048,20, 4096,19, 8192,18, 16384,17, 32768,16,
65536,15, 0x20000,14, 0x40000,13, 0x80000,12, 0x100000,11,
0x200000,10, 0x400000,9, 0x800000,8, 0x1000000,7, 0x2000000,6,
0x4000000,5, 0x8000000,4, 0x0FFFFFFF,4, 0x10000000,3,
0x3000FFFF,2, 0x50003333,1, 0x7FFFFFFF,1, 0x80000000,0,
0xFFFFFFFF,0};
std::size_t const Count = 10000000;
n = sizeof(test)/4;
std::clock_t TimestampBeg = 0;
std::clock_t TimestampEnd = 0;
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz1(test[i]) != test[i+1]) error(test[i], nlz1(test[i]));}
TimestampEnd = std::clock();
printf("nlz1: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz1a(test[i]) != test[i+1]) error(test[i], nlz1a(test[i]));}
TimestampEnd = std::clock();
printf("nlz1a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz2(test[i]) != test[i+1]) error(test[i], nlz2(test[i]));}
TimestampEnd = std::clock();
printf("nlz2: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz2a(test[i]) != test[i+1]) error(test[i], nlz2a(test[i]));}
TimestampEnd = std::clock();
printf("nlz2a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz3(test[i]) != test[i+1]) error(test[i], nlz3(test[i]));}
TimestampEnd = std::clock();
printf("nlz3: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz4(test[i]) != test[i+1]) error(test[i], nlz4(test[i]));}
TimestampEnd = std::clock();
printf("nlz4: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz5(test[i]) != test[i+1]) error(test[i], nlz5(test[i]));}
TimestampEnd = std::clock();
printf("nlz5: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz6(test[i]) != test[i+1]) error(test[i], nlz6(test[i]));}
TimestampEnd = std::clock();
printf("nlz6: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz7(test[i]) != test[i+1]) error(test[i], nlz7(test[i]));}
TimestampEnd = std::clock();
printf("nlz7: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz8(test[i]) != test[i+1]) error(test[i], nlz8(test[i]));}
TimestampEnd = std::clock();
printf("nlz8: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz9(test[i]) != test[i+1]) error(test[i], nlz9(test[i]));}
TimestampEnd = std::clock();
printf("nlz9: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz10(test[i]) != test[i+1]) error(test[i], nlz10(test[i]));}
TimestampEnd = std::clock();
printf("nlz10: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz10a(test[i]) != test[i+1]) error(test[i], nlz10a(test[i]));}
TimestampEnd = std::clock();
printf("nlz10a: %d clocks\n", TimestampEnd - TimestampBeg);
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (nlz10b(test[i]) != test[i+1]) error(test[i], nlz10b(test[i]));}
TimestampEnd = std::clock();
printf("nlz10b: %d clocks\n", TimestampEnd - TimestampBeg);
if (errors == 0)
printf("Passed all %d cases.\n", sizeof(test)/8);
# endif//NDEBUG
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_vec4.cpp | .cpp | 10,878 | 465 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_vec4.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
//#define GLM_FORCE_AVX2
#define GLM_SWIZZLE
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <cstdio>
#include <ctime>
#include <vector>
template <int Value>
struct mask
{
enum{value = Value};
};
enum comp
{
X,
Y,
Z,
W
};
//template<comp X, comp Y, comp Z, comp W>
//__m128 swizzle(glm::vec4 const & v)
//{
// __m128 Src = _mm_set_ps(v.w, v.z, v.y, v.x);
// return _mm_shuffle_ps(Src, Src, mask<(int(W) << 6) | (int(Z) << 4) | (int(Y) << 2) | (int(X) << 0)>::value);
//}
int test_vec4_ctor()
{
int Error = 0;
{
glm::ivec4 A(1, 2, 3, 4);
glm::ivec4 B(A);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
}
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::vec4>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::vec4>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::vec4>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dvec4>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::ivec4>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::uvec4>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::vec4>::value ? 0 : 1;
# endif
#if GLM_HAS_INITIALIZER_LISTS
{
glm::vec4 a{ 0, 1, 2, 3 };
std::vector<glm::vec4> v = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 0, 1}};
}
{
glm::dvec4 a{ 0, 1, 2, 3 };
std::vector<glm::dvec4> v = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 0, 1}};
}
#endif
#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
{
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A.xyzw;
glm::vec4 C(A.xyzw);
glm::vec4 D(A.xyzw());
glm::vec4 E(A.x, A.yzw);
glm::vec4 F(A.x, A.yzw());
glm::vec4 G(A.xyz, A.w);
glm::vec4 H(A.xyz(), A.w);
glm::vec4 I(A.xy, A.zw);
glm::vec4 J(A.xy(), A.zw());
glm::vec4 K(A.x, A.y, A.zw);
glm::vec4 L(A.x, A.yz, A.w);
glm::vec4 M(A.xy, A.z, A.w);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
}
#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
{
glm::vec4 A(1);
glm::vec4 B(1, 1, 1, 1);
Error += A == B ? 0 : 1;
}
{
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(glm::vec2(1, 2), 3, 4));
Tests.push_back(glm::vec4(1, glm::vec2(2, 3), 4));
Tests.push_back(glm::vec4(1, 2, glm::vec2(3, 4)));
Tests.push_back(glm::vec4(glm::vec3(1, 2, 3), 4));
Tests.push_back(glm::vec4(1, glm::vec3(2, 3, 4)));
Tests.push_back(glm::vec4(glm::vec2(1, 2), glm::vec2(3, 4)));
Tests.push_back(glm::vec4(1, 2, 3, 4));
Tests.push_back(glm::vec4(glm::vec4(1, 2, 3, 4)));
for(std::size_t i = 0; i < Tests.size(); ++i)
Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1;
}
return Error;
}
int test_vec4_operators()
{
int Error = 0;
{
glm::vec4 A(1.0f);
glm::vec4 B(1.0f);
bool R = A != B;
bool S = A == B;
Error += (S && !R) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
glm::vec4 C = A + B;
Error += C == glm::vec4(5, 7, 9, 11) ? 0 : 1;
glm::vec4 D = B - A;
Error += D == glm::vec4(3, 3, 3, 3) ? 0 : 1;
glm::vec4 E = A * B;
Error += E == glm::vec4(4, 10, 18, 28) ? 0 : 1;
glm::vec4 F = B / A;
Error += F == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
glm::vec4 G = A + 1.0f;
Error += G == glm::vec4(2, 3, 4, 5) ? 0 : 1;
glm::vec4 H = B - 1.0f;
Error += H == glm::vec4(3, 4, 5, 6) ? 0 : 1;
glm::vec4 I = A * 2.0f;
Error += I == glm::vec4(2, 4, 6, 8) ? 0 : 1;
glm::vec4 J = B / 2.0f;
Error += J == glm::vec4(2, 2.5, 3, 3.5) ? 0 : 1;
glm::vec4 K = 1.0f + A;
Error += K == glm::vec4(2, 3, 4, 5) ? 0 : 1;
glm::vec4 L = 1.0f - B;
Error += L == glm::vec4(-3, -4, -5, -6) ? 0 : 1;
glm::vec4 M = 2.0f * A;
Error += M == glm::vec4(2, 4, 6, 8) ? 0 : 1;
glm::vec4 N = 2.0f / B;
Error += N == glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
A += B;
Error += A == glm::vec4(5, 7, 9, 11) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec4(6, 8, 10, 12) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
B -= A;
Error += B == glm::vec4(3, 3, 3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec4(2, 2, 2, 2) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
A *= B;
Error += A == glm::vec4(4, 10, 18, 28) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec4(8, 20, 36, 56) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
B /= A;
Error += B == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec4(2, 1.25, 1, 7.0f / 4.0f / 2.0f) ? 0 : 1;
}
{
glm::vec4 B(2.0f);
B /= B.y;
Error += B == glm::vec4(1.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = -A;
Error += B == glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = --A;
Error += B == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A--;
Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
Error += A == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = ++A;
Error += B == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A++;
Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
Error += A == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
}
return Error;
}
int test_vec4_size()
{
int Error = 0;
Error += sizeof(glm::vec4) == sizeof(glm::lowp_vec4) ? 0 : 1;
Error += sizeof(glm::vec4) == sizeof(glm::mediump_vec4) ? 0 : 1;
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
Error += 16 == sizeof(glm::mediump_vec4) ? 0 : 1;
Error += sizeof(glm::dvec4) == sizeof(glm::lowp_dvec4) ? 0 : 1;
Error += sizeof(glm::dvec4) == sizeof(glm::mediump_dvec4) ? 0 : 1;
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
Error += 32 == sizeof(glm::highp_dvec4) ? 0 : 1;
Error += glm::vec4().length() == 4 ? 0 : 1;
Error += glm::dvec4().length() == 4 ? 0 : 1;
return Error;
}
int test_vec4_swizzle_partial()
{
int Error = 0;
glm::vec4 A(1, 2, 3, 4);
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE_RELAX)
{
glm::vec4 B(A.xy, A.zw);
Error += A == B ? 0 : 1;
}
{
glm::vec4 B(A.xy, 3.0f, 4.0f);
Error += A == B ? 0 : 1;
}
{
glm::vec4 B(1.0f, A.yz, 4.0f);
Error += A == B ? 0 : 1;
}
{
glm::vec4 B(1.0f, 2.0f, A.zw);
Error += A == B ? 0 : 1;
}
{
glm::vec4 B(A.xyz, 4.0f);
Error += A == B ? 0 : 1;
}
{
glm::vec4 B(1.0f, A.yzw);
Error += A == B ? 0 : 1;
}
# endif
return Error;
}
int test_operator_increment()
{
int Error(0);
glm::ivec4 v0(1);
glm::ivec4 v1(v0);
glm::ivec4 v2(v0);
glm::ivec4 v3 = ++v1;
glm::ivec4 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
struct AoS
{
glm::vec4 A;
glm::vec3 B;
glm::vec3 C;
glm::vec2 D;
};
int test_vec4_perf_AoS(std::size_t Size)
{
int Error(0);
std::vector<AoS> In;
std::vector<AoS> Out;
In.resize(Size);
Out.resize(Size);
std::clock_t StartTime = std::clock();
for(std::size_t i = 0; i < In.size(); ++i)
Out[i] = In[i];
std::clock_t EndTime = std::clock();
std::printf("AoS: %d\n", EndTime - StartTime);
return Error;
}
int test_vec4_perf_SoA(std::size_t Size)
{
int Error(0);
std::vector<glm::vec4> InA;
std::vector<glm::vec3> InB;
std::vector<glm::vec3> InC;
std::vector<glm::vec2> InD;
std::vector<glm::vec4> OutA;
std::vector<glm::vec3> OutB;
std::vector<glm::vec3> OutC;
std::vector<glm::vec2> OutD;
InA.resize(Size);
InB.resize(Size);
InC.resize(Size);
InD.resize(Size);
OutA.resize(Size);
OutB.resize(Size);
OutC.resize(Size);
OutD.resize(Size);
std::clock_t StartTime = std::clock();
for(std::size_t i = 0; i < InA.size(); ++i)
{
OutA[i] = InA[i];
OutB[i] = InB[i];
OutC[i] = InC[i];
OutD[i] = InD[i];
}
std::clock_t EndTime = std::clock();
std::printf("SoA: %d\n", EndTime - StartTime);
return Error;
}
int main()
{
int Error(0);
std::size_t const Size(1000000);
# ifdef NDEBUG
Error += test_vec4_perf_AoS(Size);
Error += test_vec4_perf_SoA(Size);
# endif//NDEBUG
Error += test_vec4_ctor();
Error += test_vec4_size();
Error += test_vec4_operators();
Error += test_vec4_swizzle_partial();
Error += test_operator_increment();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat3x3.cpp | .cpp | 4,677 | 172 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat3x3.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
#include <glm/mat3x3.hpp>
#include <cstdio>
#include <vector>
void print(glm::dmat3 const & Mat0)
{
printf("mat3(\n");
printf("\tvec3(%2.3f, %2.3f, %2.3f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2]);
printf("\tvec3(%2.3f, %2.3f, %2.3f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2]);
printf("\tvec3(%2.3f, %2.3f, %2.3f))\n\n", Mat0[2][0], Mat0[2][1], Mat0[2][2]);
}
int test_mat3x3()
{
glm::dmat3 Mat0(
glm::dvec3(0.6f, 0.2f, 0.3f),
glm::dvec3(0.2f, 0.7f, 0.5f),
glm::dvec3(0.3f, 0.5f, 0.7f));
glm::dmat3 Inv0 = glm::inverse(Mat0);
glm::dmat3 Res0 = Mat0 * Inv0;
print(Mat0);
print(Inv0);
print(Res0);
return 0;
}
static int test_operators()
{
glm::mat3x3 l(1.0f);
glm::mat3x3 m(1.0f);
glm::vec3 u(1.0f);
glm::vec3 v(1.0f);
float x = 1.0f;
glm::vec3 a = m * u;
glm::vec3 b = v * m;
glm::mat3x3 n = x / m;
glm::mat3x3 o = m / x;
glm::mat3x3 p = x * m;
glm::mat3x3 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_inverse()
{
int Error(0);
{
glm::mat3 const Matrix(
glm::vec3(0.6f, 0.2f, 0.3f),
glm::vec3(0.2f, 0.7f, 0.5f),
glm::vec3(0.3f, 0.5f, 0.7f));
glm::mat3 const Inverse = glm::inverse(Matrix);
glm::mat3 const Identity = Matrix * Inverse;
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
}
{
glm::mat3 const Matrix(
glm::vec3(0.6f, 0.2f, 0.3f),
glm::vec3(0.2f, 0.7f, 0.5f),
glm::vec3(0.3f, 0.5f, 0.7f));
glm::mat3 const Identity = Matrix / Matrix;
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
}
return Error;
}
int test_ctr()
{
int Error(0);
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat3x3 m0(
glm::vec3(0, 1, 2),
glm::vec3(3, 4, 5),
glm::vec3(6, 7, 8));
glm::mat3x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8};
glm::mat3x3 m2{
{0, 1, 2},
{3, 4, 5},
{6, 7, 8}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat3x3> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8}
};
std::vector<glm::mat3x3> v2{
{
{ 0, 1, 2},
{ 3, 4, 5},
{ 6, 7, 8}
},
{
{ 0, 1, 2},
{ 3, 4, 5},
{ 6, 7, 8}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_mat3x3();
Error += test_operators();
Error += test_inverse();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_geometric.cpp | .cpp | 6,187 | 218 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_geometric.cpp
/// @date 2011-01-15 / 2011-09-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/geometric.hpp>
#include <glm/vector_relational.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/vec1.hpp>
#include <limits>
namespace length
{
int test()
{
float Length1 = glm::length(glm::vec1(1));
float Length2 = glm::length(glm::vec2(1, 0));
float Length3 = glm::length(glm::vec3(1, 0, 0));
float Length4 = glm::length(glm::vec4(1, 0, 0, 0));
int Error = 0;
Error += glm::abs(Length1 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Length2 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Length3 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Length4 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
return Error;
}
}//namespace length
namespace distance
{
int test()
{
float Distance1 = glm::distance(glm::vec1(1), glm::vec1(1));
float Distance2 = glm::distance(glm::vec2(1, 0), glm::vec2(1, 0));
float Distance3 = glm::distance(glm::vec3(1, 0, 0), glm::vec3(1, 0, 0));
float Distance4 = glm::distance(glm::vec4(1, 0, 0, 0), glm::vec4(1, 0, 0, 0));
int Error = 0;
Error += glm::abs(Distance1) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Distance2) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Distance3) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Distance4) < std::numeric_limits<float>::epsilon() ? 0 : 1;
return Error;
}
}//namespace distance
namespace dot
{
int test()
{
float Dot1 = glm::dot(glm::vec1(1), glm::vec1(1));
float Dot2 = glm::dot(glm::vec2(1), glm::vec2(1));
float Dot3 = glm::dot(glm::vec3(1), glm::vec3(1));
float Dot4 = glm::dot(glm::vec4(1), glm::vec4(1));
int Error = 0;
Error += glm::abs(Dot1 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Dot2 - 2.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Dot3 - 3.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
Error += glm::abs(Dot4 - 4.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
return Error;
}
}//namespace dot
namespace cross
{
int test()
{
glm::vec3 Cross1 = glm::cross(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
glm::vec3 Cross2 = glm::cross(glm::vec3(0, 1, 0), glm::vec3(1, 0, 0));
int Error = 0;
Error += glm::all(glm::lessThan(glm::abs(Cross1 - glm::vec3(0, 0, 1)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
Error += glm::all(glm::lessThan(glm::abs(Cross2 - glm::vec3(0, 0,-1)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
return Error;
}
}//namespace cross
namespace normalize
{
int test()
{
glm::vec3 Normalize1 = glm::normalize(glm::vec3(1, 0, 0));
glm::vec3 Normalize2 = glm::normalize(glm::vec3(2, 0, 0));
int Error = 0;
Error += glm::all(glm::lessThan(glm::abs(Normalize1 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
Error += glm::all(glm::lessThan(glm::abs(Normalize2 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
return Error;
}
}//namespace normalize
namespace faceforward
{
int test()
{
int Error = 0;
{
glm::vec3 N(0.0f, 0.0f, 1.0f);
glm::vec3 I(1.0f, 0.0f, 1.0f);
glm::vec3 Nref(0.0f, 0.0f, 1.0f);
glm::vec3 F = glm::faceforward(N, I, Nref);
}
return Error;
}
}//namespace faceforward
namespace reflect
{
int test()
{
int Error = 0;
{
glm::vec2 A(1.0f,-1.0f);
glm::vec2 B(0.0f, 1.0f);
glm::vec2 C = glm::reflect(A, B);
Error += C == glm::vec2(1.0, 1.0) ? 0 : 1;
}
{
glm::dvec2 A(1.0f,-1.0f);
glm::dvec2 B(0.0f, 1.0f);
glm::dvec2 C = glm::reflect(A, B);
Error += C == glm::dvec2(1.0, 1.0) ? 0 : 1;
}
return Error;
}
}//namespace reflect
namespace refract
{
int test()
{
int Error = 0;
{
float A(-1.0f);
float B(1.0f);
float C = glm::refract(A, B, 0.5f);
Error += C == -1.0f ? 0 : 1;
}
{
glm::vec2 A(0.0f,-1.0f);
glm::vec2 B(0.0f, 1.0f);
glm::vec2 C = glm::refract(A, B, 0.5f);
Error += glm::all(glm::epsilonEqual(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1;
}
{
glm::dvec2 A(0.0f,-1.0f);
glm::dvec2 B(0.0f, 1.0f);
glm::dvec2 C = glm::refract(A, B, 0.5);
Error += C == glm::dvec2(0.0, -1.0) ? 0 : 1;
}
return Error;
}
}//namespace refract
int main()
{
int Error(0);
Error += length::test();
Error += distance::test();
Error += dot::test();
Error += cross::test();
Error += normalize::test();
Error += faceforward::test();
Error += reflect::test();
Error += refract::test();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_swizzle.cpp | .cpp | 2,646 | 109 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_func_swizzle.cpp
/// @date 2011-10-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_MESSAGES
#define GLM_SWIZZLE
#include <glm/glm.hpp>
int test_ivec2_swizzle()
{
int Error = 0;
glm::ivec2 A(1, 2);
glm::ivec2 B = A.yx();
glm::ivec2 C = B.yx();
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
return Error;
}
int test_ivec3_swizzle()
{
int Error = 0;
glm::ivec3 A(1, 2, 3);
glm::ivec3 B = A.zyx();
glm::ivec3 C = B.zyx();
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
return Error;
}
int test_ivec4_swizzle()
{
int Error = 0;
glm::ivec4 A(1, 2, 3, 4);
glm::ivec4 B = A.wzyx();
glm::ivec4 C = B.wzyx();
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
return Error;
}
int test_vec4_swizzle()
{
int Error = 0;
glm::vec4 A(1, 2, 3, 4);
glm::vec4 B = A.wzyx();
glm::vec4 C = B.wzyx();
float f = glm::dot(C.wzyx(), C.xyzw());
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_ivec2_swizzle();
Error += test_ivec3_swizzle();
Error += test_ivec4_swizzle();
Error += test_vec4_swizzle();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_packing.cpp | .cpp | 4,823 | 182 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_packing.cpp
/// @date 2011-01-15 / 2011-09-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp>
#include <glm/packing.hpp>
#include <vector>
int test_packUnorm2x16()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2(1.0f, 0.0f));
A.push_back(glm::vec2(0.5f, 0.7f));
A.push_back(glm::vec2(0.1f, 0.2f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint32 C = glm::packUnorm2x16(B);
glm::vec2 D = glm::unpackUnorm2x16(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm2x16()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2( 1.0f, 0.0f));
A.push_back(glm::vec2(-0.5f,-0.7f));
A.push_back(glm::vec2(-0.1f, 0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint32 C = glm::packSnorm2x16(B);
glm::vec2 D = glm::unpackSnorm2x16(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packUnorm4x8()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f));
A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint32 C = glm::packUnorm4x8(B);
glm::vec4 D = glm::unpackUnorm4x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm4x8()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4( 1.0f, 0.0f,-0.5f,-1.0f));
A.push_back(glm::vec4(-0.7f,-0.1f, 0.1f, 0.7f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint32 C = glm::packSnorm4x8(B);
glm::vec4 D = glm::unpackSnorm4x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packHalf2x16()
{
int Error = 0;
/*
std::vector<glm::hvec2> A;
A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 2.0f)));
A.push_back(glm::hvec2(glm::half(-1.0f), glm::half(-2.0f)));
A.push_back(glm::hvec2(glm::half(-1.1f), glm::half( 1.1f)));
*/
std::vector<glm::vec2> A;
A.push_back(glm::vec2( 1.0f, 2.0f));
A.push_back(glm::vec2(-1.0f,-2.0f));
A.push_back(glm::vec2(-1.1f, 1.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint C = glm::packHalf2x16(B);
glm::vec2 D = glm::unpackHalf2x16(C);
//Error += B == D ? 0 : 1;
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packDouble2x32()
{
int Error = 0;
std::vector<glm::uvec2> A;
A.push_back(glm::uvec2( 1, 2));
A.push_back(glm::uvec2(-1,-2));
A.push_back(glm::uvec2(-1000, 1100));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::uvec2 B(A[i]);
double C = glm::packDouble2x32(B);
glm::uvec2 D = glm::unpackDouble2x32(C);
Error += B == D ? 0 : 1;
assert(!Error);
}
return Error;
}
int main()
{
int Error = 0;
Error += test_packSnorm4x8();
Error += test_packUnorm4x8();
Error += test_packSnorm2x16();
Error += test_packUnorm2x16();
Error += test_packHalf2x16();
Error += test_packDouble2x32();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_exponential.cpp | .cpp | 3,872 | 150 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_exponential.cpp
/// @date 2011-01-15 / 2011-09-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/common.hpp>
#include <glm/exponential.hpp>
#include <glm/gtc/ulp.hpp>
#include <glm/gtc/vec1.hpp>
int test_pow()
{
int Error(0);
float A = glm::pow(10.f, 10.f);
glm::vec1 B = glm::pow(glm::vec1(10.f), glm::vec1(10.f));
glm::vec2 C = glm::pow(glm::vec2(10.f), glm::vec2(10.f));
glm::vec3 D = glm::pow(glm::vec3(10.f), glm::vec3(10.f));
glm::vec4 E = glm::pow(glm::vec4(10.f), glm::vec4(10.f));
return Error;
}
int test_exp()
{
int Error(0);
float A = glm::exp(10.f);
glm::vec1 B = glm::exp(glm::vec1(10.f));
glm::vec2 C = glm::exp(glm::vec2(10.f));
glm::vec3 D = glm::exp(glm::vec3(10.f));
glm::vec4 E = glm::exp(glm::vec4(10.f));
return Error;
}
int test_log()
{
int Error(0);
float A = glm::log(10.f);
glm::vec1 B = glm::log(glm::vec1(10.f));
glm::vec2 C = glm::log(glm::vec2(10.f));
glm::vec3 D = glm::log(glm::vec3(10.f));
glm::vec4 E = glm::log(glm::vec4(10.f));
return Error;
}
int test_exp2()
{
int Error(0);
float A = glm::exp2(10.f);
glm::vec1 B = glm::exp2(glm::vec1(10.f));
glm::vec2 C = glm::exp2(glm::vec2(10.f));
glm::vec3 D = glm::exp2(glm::vec3(10.f));
glm::vec4 E = glm::exp2(glm::vec4(10.f));
return Error;
}
int test_log2()
{
int Error(0);
float A = glm::log2(10.f);
glm::vec1 B = glm::log2(glm::vec1(10.f));
glm::vec2 C = glm::log2(glm::vec2(10.f));
glm::vec3 D = glm::log2(glm::vec3(10.f));
glm::vec4 E = glm::log2(glm::vec4(10.f));
return Error;
}
int test_sqrt()
{
int Error(0);
float A = glm::sqrt(10.f);
glm::vec1 B = glm::sqrt(glm::vec1(10.f));
glm::vec2 C = glm::sqrt(glm::vec2(10.f));
glm::vec3 D = glm::sqrt(glm::vec3(10.f));
glm::vec4 E = glm::sqrt(glm::vec4(10.f));
return Error;
}
int test_inversesqrt()
{
int Error(0);
glm::uint ulp(0);
float diff(0.0f);
for(float f = 0.001f; f < 10.f; f *= 1.001f)
{
glm::lowp_fvec1 u(f);
glm::lowp_fvec1 lowp_v = glm::inversesqrt(u);
float defaultp_v = glm::inversesqrt(f);
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
diff = glm::abs(lowp_v.x - defaultp_v);
}
return Error;
}
int main()
{
int Error(0);
Error += test_pow();
Error += test_exp();
Error += test_log();
Error += test_exp2();
Error += test_log2();
Error += test_sqrt();
Error += test_inversesqrt();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_setup_precision.cpp | .cpp | 3,202 | 90 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_setup_precision.cpp
/// @date 2011-05-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_INLINE
#define GLM_PRECISION_HIGHP_FLOAT
#include <glm/glm.hpp>
#include <glm/ext.hpp>
static int test_mat()
{
int Error = 0;
Error += sizeof(glm::mat2) == sizeof(glm::highp_mat2) ? 0 : 1;
Error += sizeof(glm::mat3) == sizeof(glm::highp_mat3) ? 0 : 1;
Error += sizeof(glm::mat4) == sizeof(glm::highp_mat4) ? 0 : 1;
Error += sizeof(glm::mat2x2) == sizeof(glm::highp_mat2x2) ? 0 : 1;
Error += sizeof(glm::mat2x3) == sizeof(glm::highp_mat2x3) ? 0 : 1;
Error += sizeof(glm::mat2x4) == sizeof(glm::highp_mat2x4) ? 0 : 1;
Error += sizeof(glm::mat3x2) == sizeof(glm::highp_mat3x2) ? 0 : 1;
Error += sizeof(glm::mat3x3) == sizeof(glm::highp_mat3x3) ? 0 : 1;
Error += sizeof(glm::mat3x4) == sizeof(glm::highp_mat3x4) ? 0 : 1;
Error += sizeof(glm::mat4x2) == sizeof(glm::highp_mat4x2) ? 0 : 1;
Error += sizeof(glm::mat4x3) == sizeof(glm::highp_mat4x3) ? 0 : 1;
Error += sizeof(glm::mat4x4) == sizeof(glm::highp_mat4x4) ? 0 : 1;
return Error;
}
static int test_vec()
{
int Error = 0;
Error += sizeof(glm::vec2) == sizeof(glm::highp_vec2) ? 0 : 1;
Error += sizeof(glm::vec3) == sizeof(glm::highp_vec3) ? 0 : 1;
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
return Error;
}
static int test_dvec()
{
int Error = 0;
Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1;
Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1;
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_mat();
Error += test_vec();
Error += test_dvec();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_vec1.cpp | .cpp | 4,520 | 179 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_vec1.cpp
/// @date 2014-10-11 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE
#include <glm/vector_relational.hpp>
#include <glm/gtc/vec1.hpp>
#include <vector>
int test_vec1_operators()
{
int Error(0);
glm::vec1 A(1.0f);
glm::vec1 B(1.0f);
{
bool R = A != B;
bool S = A == B;
Error += (S && !R) ? 0 : 1;
}
{
A *= 1.0f;
B *= 1.0;
A += 1.0f;
B += 1.0;
bool R = A != B;
bool S = A == B;
Error += (S && !R) ? 0 : 1;
}
return Error;
}
int test_vec1_ctor()
{
int Error = 0;
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::vec1>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::vec1>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::vec1>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dvec1>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::ivec1>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::uvec1>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::vec1>::value ? 0 : 1;
# endif
/*
#if GLM_HAS_INITIALIZER_LISTS
{
glm::vec1 a{ 0 };
std::vector<glm::vec1> v = {
{0.f},
{4.f},
{8.f}};
}
{
glm::dvec2 a{ 0 };
std::vector<glm::dvec1> v = {
{0.0},
{4.0},
{8.0}};
}
#endif
*/
#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
{
glm::vec2 A = glm::vec2(1.0f, 2.0f);
glm::vec2 B = A.xy;
glm::vec2 C(A.xy);
glm::vec2 D(A.xy());
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
}
#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
{
glm::vec2 A = glm::vec2(2.0f);
glm::vec2 B = glm::vec2(2.0f, 3.0f);
glm::vec2 C = glm::vec2(2.0f, 3.0);
//glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says?
glm::vec2 E(glm::dvec2(2.0));
glm::vec2 F(glm::ivec2(2));
}
return Error;
}
int test_vec1_size()
{
int Error = 0;
Error += sizeof(glm::vec1) == sizeof(glm::mediump_vec1) ? 0 : 1;
Error += 4 == sizeof(glm::mediump_vec1) ? 0 : 1;
Error += sizeof(glm::dvec1) == sizeof(glm::highp_dvec1) ? 0 : 1;
Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1;
Error += glm::vec1().length() == 1 ? 0 : 1;
Error += glm::dvec1().length() == 1 ? 0 : 1;
return Error;
}
int test_vec1_operator_increment()
{
int Error(0);
glm::ivec1 v0(1);
glm::ivec1 v1(v0);
glm::ivec1 v2(v0);
glm::ivec1 v3 = ++v1;
glm::ivec1 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
glm::vec1 v;
assert(v.length() == 1);
Error += test_vec1_size();
Error += test_vec1_ctor();
Error += test_vec1_operators();
Error += test_vec1_operator_increment();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_vec3.cpp | .cpp | 14,661 | 509 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_vec3.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE
#include <glm/vector_relational.hpp>
#include <glm/geometric.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <cstdio>
#include <vector>
int test_vec3_ctor()
{
int Error = 0;
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::vec3>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::vec3>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::vec3>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dvec3>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::ivec3>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::uvec3>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::vec3>::value ? 0 : 1;
# endif
#if (GLM_HAS_INITIALIZER_LISTS)
{
glm::vec3 a{ 0, 1, 2 };
std::vector<glm::vec3> v = {
{0, 1, 2},
{4, 5, 6},
{8, 9, 0}};
}
{
glm::dvec3 a{ 0, 1, 2 };
std::vector<glm::dvec3> v = {
{0, 1, 2},
{4, 5, 6},
{8, 9, 0}};
}
#endif
#if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
{
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
glm::vec3 B = A.xyz;
glm::vec3 C(A.xyz);
glm::vec3 D(A.xyz());
glm::vec3 E(A.x, A.yz);
glm::vec3 F(A.x, A.yz());
glm::vec3 G(A.xy, A.z);
glm::vec3 H(A.xy(), A.z);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
}
#endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
{
glm::vec3 A(1);
glm::vec3 B(1, 1, 1);
Error += A == B ? 0 : 1;
}
{
std::vector<glm::vec3> Tests;
Tests.push_back(glm::vec3(glm::vec2(1, 2), 3));
Tests.push_back(glm::vec3(1, glm::vec2(2, 3)));
Tests.push_back(glm::vec3(1, 2, 3));
Tests.push_back(glm::vec3(glm::vec4(1, 2, 3, 4)));
for(std::size_t i = 0; i < Tests.size(); ++i)
Error += Tests[i] == glm::vec3(1, 2, 3) ? 0 : 1;
}
return Error;
}
int test_vec3_operators()
{
int Error = 0;
{
glm::vec3 A(1.0f);
glm::vec3 B(1.0f);
bool R = A != B;
bool S = A == B;
Error += (S && !R) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
glm::vec3 C = A + B;
Error += C == glm::vec3(5, 7, 9) ? 0 : 1;
glm::vec3 D = B - A;
Error += D == glm::vec3(3, 3, 3) ? 0 : 1;
glm::vec3 E = A * B;
Error += E == glm::vec3(4, 10, 18) ? 0 : 1;
glm::vec3 F = B / A;
Error += F == glm::vec3(4, 2.5, 2) ? 0 : 1;
glm::vec3 G = A + 1.0f;
Error += G == glm::vec3(2, 3, 4) ? 0 : 1;
glm::vec3 H = B - 1.0f;
Error += H == glm::vec3(3, 4, 5) ? 0 : 1;
glm::vec3 I = A * 2.0f;
Error += I == glm::vec3(2, 4, 6) ? 0 : 1;
glm::vec3 J = B / 2.0f;
Error += J == glm::vec3(2, 2.5, 3) ? 0 : 1;
glm::vec3 K = 1.0f + A;
Error += K == glm::vec3(2, 3, 4) ? 0 : 1;
glm::vec3 L = 1.0f - B;
Error += L == glm::vec3(-3, -4, -5) ? 0 : 1;
glm::vec3 M = 2.0f * A;
Error += M == glm::vec3(2, 4, 6) ? 0 : 1;
glm::vec3 N = 2.0f / B;
Error += N == glm::vec3(0.5, 2.0 / 5.0, 2.0 / 6.0) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
A += B;
Error += A == glm::vec3(5, 7, 9) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec3(6, 8, 10) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
B -= A;
Error += B == glm::vec3(3, 3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec3(2, 2, 2) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
A *= B;
Error += A == glm::vec3(4, 10, 18) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec3(8, 20, 36) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
B /= A;
Error += B == glm::vec3(4, 2.5, 2) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec3(2, 1.25, 1) ? 0 : 1;
}
{
glm::vec3 B(2.0f);
B /= B.y;
Error += B == glm::vec3(1.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = -A;
Error += B == glm::vec3(-1.0f, -2.0f, -3.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = --A;
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = A--;
Error += B == glm::vec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
Error += A == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = ++A;
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = A++;
Error += B == glm::vec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
Error += A == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
}
return Error;
}
int test_vec3_size()
{
int Error = 0;
Error += sizeof(glm::vec3) == sizeof(glm::lowp_vec3) ? 0 : 1;
Error += sizeof(glm::vec3) == sizeof(glm::mediump_vec3) ? 0 : 1;
Error += sizeof(glm::vec3) == sizeof(glm::highp_vec3) ? 0 : 1;
Error += 12 == sizeof(glm::mediump_vec3) ? 0 : 1;
Error += sizeof(glm::dvec3) == sizeof(glm::lowp_dvec3) ? 0 : 1;
Error += sizeof(glm::dvec3) == sizeof(glm::mediump_dvec3) ? 0 : 1;
Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1;
Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1;
Error += glm::vec3().length() == 3 ? 0 : 1;
Error += glm::dvec3().length() == 3 ? 0 : 1;
return Error;
}
int test_vec3_swizzle3_2()
{
int Error = 0;
glm::vec3 v(1, 2, 3);
glm::vec2 u;
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
// Can not assign a vec3 swizzle to a vec2
//u = v.xyz; //Illegal
//u = v.rgb; //Illegal
//u = v.stp; //Illegal
u = v.xx; Error += (u.x == 1.0f && u.y == 1.0f) ? 0 : 1;
u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1;
u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1;
u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1;
u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1;
u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1;
u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1;
u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1;
u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1;
u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1;
u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1;
u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1;
u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1;
u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1;
u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1;
u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1;
u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1;
u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1;
u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1;
u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1;
u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1;
u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1;
u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1;
u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1;
u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1;
u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1;
u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1;
// Mixed member aliases are not valid
//u = v.rx; //Illegal
//u = v.sy; //Illegal
u = glm::vec2(1, 2);
v = glm::vec3(1, 2, 3);
//v.xx = u; //Illegal
v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1;
v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1;
v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
//v.yy = u; //Illegal
v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1;
v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1;
//v.zz = u; //Illegal
# endif//GLM_LANG
return Error;
}
int test_vec3_swizzle3_3()
{
int Error = 0;
glm::vec3 v(1, 2, 3);
glm::vec3 u;
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
# endif//GLM_LANG
return Error;
}
int test_vec3_swizzle_operators()
{
int Error = 0;
glm::vec3 q, u, v;
u = glm::vec3(1, 2, 3);
v = glm::vec3(10, 20, 30);
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
// Swizzle, swizzle binary operators
q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1;
q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1;
q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1;
q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1;
q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1;
q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1;
// vec, swizzle binary operators
q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1;
q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1;
q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1;
q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1;
q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1;
// swizzle,vec binary operators
q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1;
q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1;
q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1;
q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1;
q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1;
# endif//GLM_LANG
// Compile errors
//q = (u.yz * v.xyz);
//q = (u * v.xy);
return Error;
}
int test_vec3_swizzle_functions()
{
int Error = 0;
// NOTE: template functions cannot pick up the implicit conversion from
// a swizzle to the unswizzled type, therefore the operator() must be
// used. E.g.:
//
// glm::dot(u.xy, v.xy); <--- Compile error
// glm::dot(u.xy(), v.xy()); <--- Compiles correctly
float r;
// vec2
glm::vec2 a(1, 2);
glm::vec2 b(10, 20);
r = glm::dot(a, b); Error += (int(r) == 50) ? 0 : 1;
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.xy())); Error += (int(r) == 50) ? 0 : 1;
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.yy())); Error += (int(r) == 60) ? 0 : 1;
// vec3
glm::vec3 q, u, v;
u = glm::vec3(1, 2, 3);
v = glm::vec3(10, 20, 30);
r = glm::dot(u, v); Error += (int(r) == 140) ? 0 : 1;
r = glm::dot(u.xyz(), v.zyz()); Error += (int(r) == 160) ? 0 : 1;
r = glm::dot(u, v.zyx()); Error += (int(r) == 100) ? 0 : 1;
r = glm::dot(u.xyz(), v); Error += (int(r) == 140) ? 0 : 1;
r = glm::dot(u.xy(), v.xy()); Error += (int(r) == 50) ? 0 : 1;
// vec4
glm::vec4 s, t;
s = glm::vec4(1, 2, 3, 4);
t = glm::vec4(10, 20, 30, 40);
r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
return Error;
}
int test_vec3_swizzle_partial()
{
int Error = 0;
glm::vec3 A(1, 2, 3);
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
{
glm::vec3 B(A.xy, 3.0f);
Error += A == B ? 0 : 1;
}
{
glm::vec3 B(1.0f, A.yz);
Error += A == B ? 0 : 1;
}
{
glm::vec3 B(A.xyz);
Error += A == B ? 0 : 1;
}
# endif//GLM_LANG
return Error;
}
int test_operator_increment()
{
int Error(0);
glm::ivec3 v0(1);
glm::ivec3 v1(v0);
glm::ivec3 v2(v0);
glm::ivec3 v3 = ++v1;
glm::ivec3 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_vec3_ctor();
Error += test_vec3_operators();
Error += test_vec3_size();
Error += test_vec3_swizzle3_2();
Error += test_vec3_swizzle3_3();
Error += test_vec3_swizzle_partial();
Error += test_vec3_swizzle_operators();
Error += test_vec3_swizzle_functions();
Error += test_operator_increment();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat2x3.cpp | .cpp | 2,781 | 106 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat2x3.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x3.hpp>
#include <vector>
static int test_operators()
{
glm::mat2x3 l(1.0f);
glm::mat2x3 m(1.0f);
glm::vec2 u(1.0f);
glm::vec3 v(1.0f);
float x = 1.0f;
glm::vec3 a = m * u;
glm::vec2 b = v * m;
glm::mat2x3 n = x / m;
glm::mat2x3 o = m / x;
glm::mat2x3 p = x * m;
glm::mat2x3 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_ctr()
{
int Error(0);
#if GLM_HAS_INITIALIZER_LISTS
glm::mat2x3 m0(
glm::vec3(0, 1, 2),
glm::vec3(3, 4, 5));
glm::mat2x3 m1{0, 1, 2, 3, 4, 5};
glm::mat2x3 m2{
{0, 1, 2},
{3, 4, 5}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat2x3> v1{
{0, 1, 2, 3, 4, 5},
{0, 1, 2, 3, 4, 5}
};
std::vector<glm::mat2x3> v2{
{
{ 0, 1, 2},
{ 4, 5, 6}
},
{
{ 0, 1, 2},
{ 4, 5, 6}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_trigonometric.cpp | .cpp | 1,689 | 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/core/core_func_trigonometric.cpp
/// @date 2011-01-15 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/trigonometric.hpp>
int main()
{
int Failed = 0;
return Failed;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_int.cpp | .cpp | 2,483 | 75 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_int.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
int test_int_size()
{
return
sizeof(glm::int_t) != sizeof(glm::lowp_int) &&
sizeof(glm::int_t) != sizeof(glm::mediump_int) &&
sizeof(glm::int_t) != sizeof(glm::highp_int);
}
int test_uint_size()
{
return
sizeof(glm::uint_t) != sizeof(glm::lowp_uint) &&
sizeof(glm::uint_t) != sizeof(glm::mediump_uint) &&
sizeof(glm::uint_t) != sizeof(glm::highp_uint);
}
int test_int_precision()
{
return (
sizeof(glm::lowp_int) <= sizeof(glm::mediump_int) &&
sizeof(glm::mediump_int) <= sizeof(glm::highp_int)) ? 0 : 1;
}
int test_uint_precision()
{
return (
sizeof(glm::lowp_uint) <= sizeof(glm::mediump_uint) &&
sizeof(glm::mediump_uint) <= sizeof(glm::highp_uint)) ? 0 : 1;
}
int main()
{
int Error = 0;
Error += test_int_size();
Error += test_int_precision();
Error += test_uint_size();
Error += test_uint_precision();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat2x2.cpp | .cpp | 3,504 | 133 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat2x2.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <vector>
int test_operators()
{
glm::mat2x2 l(1.0f);
glm::mat2x2 m(1.0f);
glm::vec2 u(1.0f);
glm::vec2 v(1.0f);
float x = 1.0f;
glm::vec2 a = m * u;
glm::vec2 b = v * m;
glm::mat2x2 n = x / m;
glm::mat2x2 o = m / x;
glm::mat2x2 p = x * m;
glm::mat2x2 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_inverse()
{
int Error(0);
{
glm::mat2 const Matrix(1, 2, 3, 4);
glm::mat2 const Inverse = glm::inverse(Matrix);
glm::mat2 const Identity = Matrix * Inverse;
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
}
{
glm::mat2 const Matrix(1, 2, 3, 4);
glm::mat2 const Identity = Matrix / Matrix;
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
}
return Error;
}
int test_ctr()
{
int Error(0);
#if GLM_HAS_INITIALIZER_LISTS
glm::mat2x2 m0(
glm::vec2(0, 1),
glm::vec2(2, 3));
glm::mat2x2 m1{0, 1, 2, 3};
glm::mat2x2 m2{
{0, 1},
{2, 3}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat2x2> v1{
{0, 1, 2, 3},
{0, 1, 2, 3}
};
std::vector<glm::mat2x2> v2{
{
{ 0, 1},
{ 4, 5}
},
{
{ 0, 1},
{ 4, 5}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error(0);
Error += test_ctr();
Error += test_operators();
Error += test_inverse();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_noise.cpp | .cpp | 1,643 | 39 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_noise.cpp
/// @date 2011-01-15 / 2011-09-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
int main()
{
int Failed = 0;
return Failed;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat3x4.cpp | .cpp | 2,954 | 111 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat3x4.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat3x4.hpp>
#include <vector>
static bool test_operators()
{
glm::mat3x4 l(1.0f);
glm::mat3x4 m(1.0f);
glm::vec3 u(1.0f);
glm::vec4 v(1.0f);
float x = 1.0f;
glm::vec4 a = m * u;
glm::vec3 b = v * m;
glm::mat3x4 n = x / m;
glm::mat3x4 o = m / x;
glm::mat3x4 p = x * m;
glm::mat3x4 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_ctr()
{
int Error(0);
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat3x4 m0(
glm::vec4(0, 1, 2, 3),
glm::vec4(4, 5, 6, 7),
glm::vec4(8, 9, 10, 11));
glm::mat3x4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
glm::mat3x4 m2{
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat3x4> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
};
std::vector<glm::mat3x4> v2{
{
{ 0, 1, 2, 3},
{ 4, 5, 6, 7},
{ 8, 9, 10, 11}
},
{
{ 0, 1, 2, 3},
{ 4, 5, 6, 7},
{ 8, 9, 10, 11}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_matrix.cpp | .cpp | 7,011 | 277 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_matrix.cpp
/// @date 2007-01-25 / 2011-06-07
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/matrix.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/ulp.hpp>
#include <vector>
#include <ctime>
#include <cstdio>
using namespace glm;
int test_matrixCompMult()
{
int Error(0);
{
mat2 m(0, 1, 2, 3);
mat2 n = matrixCompMult(m, m);
Error += n == mat2(0, 1, 4, 9) ? 0 : 1;
}
{
mat2x3 m(0, 1, 2, 3, 4, 5);
mat2x3 n = matrixCompMult(m, m);
Error += n == mat2x3(0, 1, 4, 9, 16, 25) ? 0 : 1;
}
{
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
mat2x4 n = matrixCompMult(m, m);
Error += n == mat2x4(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
}
{
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
mat3 n = matrixCompMult(m, m);
Error += n == mat3(0, 1, 4, 9, 16, 25, 36, 49, 64) ? 0 : 1;
}
{
mat3x2 m(0, 1, 2, 3, 4, 5);
mat3x2 n = matrixCompMult(m, m);
Error += n == mat3x2(0, 1, 4, 9, 16, 25) ? 0 : 1;
}
{
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat3x4 n = matrixCompMult(m, m);
Error += n == mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
}
{
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
mat4 n = matrixCompMult(m, m);
Error += n == mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225) ? 0 : 1;
}
{
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
mat4x2 n = matrixCompMult(m, m);
Error += n == mat4x2(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
}
{
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat4x3 n = matrixCompMult(m, m);
Error += n == mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
}
return Error;
}
int test_outerProduct()
{
glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f));
return 0;
}
int test_transpose()
{
int Error(0);
{
mat2 m(0, 1, 2, 3);
mat2 t = transpose(m);
Error += t == mat2(0, 2, 1, 3) ? 0 : 1;
}
{
mat2x3 m(0, 1, 2, 3, 4, 5);
mat3x2 t = transpose(m);
Error += t == mat3x2(0, 3, 1, 4, 2, 5) ? 0 : 1;
}
{
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
mat4x2 t = transpose(m);
Error += t == mat4x2(0, 4, 1, 5, 2, 6, 3, 7) ? 0 : 1;
}
{
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
mat3 t = transpose(m);
Error += t == mat3(0, 3, 6, 1, 4, 7, 2, 5, 8) ? 0 : 1;
}
{
mat3x2 m(0, 1, 2, 3, 4, 5);
mat2x3 t = transpose(m);
Error += t == mat2x3(0, 2, 4, 1, 3, 5) ? 0 : 1;
}
{
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat4x3 t = transpose(m);
Error += t == mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11) ? 0 : 1;
}
{
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
mat4 t = transpose(m);
Error += t == mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) ? 0 : 1;
}
{
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
mat2x4 t = transpose(m);
Error += t == mat2x4(0, 2, 4, 6, 1, 3, 5, 7) ? 0 : 1;
}
{
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat3x4 t = transpose(m);
Error += t == mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11) ? 0 : 1;
}
return Error;
}
int test_determinant()
{
return 0;
}
int test_inverse()
{
int Failed(0);
glm::mat4x4 A4x4(
glm::vec4(1, 0, 1, 0),
glm::vec4(0, 1, 0, 0),
glm::vec4(0, 0, 1, 0),
glm::vec4(0, 0, 0, 1));
glm::mat4x4 B4x4 = inverse(A4x4);
glm::mat4x4 I4x4 = A4x4 * B4x4;
Failed += I4x4 == glm::mat4x4(1) ? 0 : 1;
glm::mat3x3 A3x3(
glm::vec3(1, 0, 1),
glm::vec3(0, 1, 0),
glm::vec3(0, 0, 1));
glm::mat3x3 B3x3 = glm::inverse(A3x3);
glm::mat3x3 I3x3 = A3x3 * B3x3;
Failed += I3x3 == glm::mat3x3(1) ? 0 : 1;
glm::mat2x2 A2x2(
glm::vec2(1, 1),
glm::vec2(0, 1));
glm::mat2x2 B2x2 = glm::inverse(A2x2);
glm::mat2x2 I2x2 = A2x2 * B2x2;
Failed += I2x2 == glm::mat2x2(1) ? 0 : 1;
return Failed;
}
std::size_t const Count(10000000);
template <typename VEC3, typename MAT4>
int test_inverse_perf(std::size_t Instance, char const * Message)
{
std::vector<MAT4> TestInputs;
TestInputs.resize(Count);
std::vector<MAT4> TestOutputs;
TestOutputs.resize(TestInputs.size());
VEC3 Axis(glm::normalize(VEC3(1.0f, 2.0f, 3.0f)));
for(std::size_t i = 0; i < TestInputs.size(); ++i)
{
typename MAT4::value_type f = static_cast<typename MAT4::value_type>(i + Instance) * typename MAT4::value_type(0.1) + typename MAT4::value_type(0.1);
TestInputs[i] = glm::rotate(glm::translate(MAT4(1), Axis * f), f, Axis);
//TestInputs[i] = glm::translate(MAT4(1), Axis * f);
}
std::clock_t StartTime = std::clock();
for(std::size_t i = 0; i < TestInputs.size(); ++i)
TestOutputs[i] = glm::inverse(TestInputs[i]);
std::clock_t EndTime = std::clock();
for(std::size_t i = 0; i < TestInputs.size(); ++i)
TestOutputs[i] = TestOutputs[i] * TestInputs[i];
typename MAT4::value_type Diff(0);
for(std::size_t Entry = 0; Entry < TestOutputs.size(); ++Entry)
{
MAT4 i(1.0);
MAT4 m(TestOutputs[Entry]);
for(glm::length_t y = 0; y < m.length(); ++y)
for(glm::length_t x = 0; x < m[y].length(); ++x)
Diff = glm::max(m[y][x], i[y][x]);
}
//glm::uint Ulp = 0;
//Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp);
printf("inverse<%s>(%f): %lu\n", Message, Diff, EndTime - StartTime);
return 0;
}
int main()
{
int Error(0);
Error += test_matrixCompMult();
Error += test_outerProduct();
Error += test_transpose();
Error += test_determinant();
Error += test_inverse();
# ifdef NDEBUG
for(std::size_t i = 0; i < 1; ++i)
{
Error += test_inverse_perf<glm::vec3, glm::mat4>(i, "mat4");
Error += test_inverse_perf<glm::dvec3, glm::dmat4>(i, "dmat4");
}
# endif//NDEBUG
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat3x2.cpp | .cpp | 2,814 | 112 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat3x2.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat3x2.hpp>
#include <vector>
static bool test_operators()
{
glm::mat3x2 l(1.0f);
glm::mat3x2 m(1.0f);
glm::vec3 u(1.0f);
glm::vec2 v(1.0f);
float x = 1.0f;
glm::vec2 a = m * u;
glm::vec3 b = v * m;
glm::mat3x2 n = x / m;
glm::mat3x2 o = m / x;
glm::mat3x2 p = x * m;
glm::mat3x2 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_ctr()
{
int Error(0);
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat3x2 m0(
glm::vec2(0, 1),
glm::vec2(2, 3),
glm::vec2(4, 5));
glm::mat3x2 m1{0, 1, 2, 3, 4, 5};
glm::mat3x2 m2{
{0, 1},
{2, 3},
{4, 5}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat3x2> v1{
{0, 1, 2, 3, 4, 5},
{0, 1, 2, 3, 4, 5}
};
std::vector<glm::mat3x2> v2{
{
{ 0, 1},
{ 2, 3},
{ 4, 5}
},
{
{ 0, 1},
{ 2, 3},
{ 4, 5}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat2x4.cpp | .cpp | 2,827 | 109 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat2x4.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x4.hpp>
#include <vector>
static int test_operators()
{
glm::mat2x4 l(1.0f);
glm::mat2x4 m(1.0f);
glm::vec2 u(1.0f);
glm::vec4 v(1.0f);
float x = 1.0f;
glm::vec4 a = m * u;
glm::vec2 b = v * m;
glm::mat2x4 n = x / m;
glm::mat2x4 o = m / x;
glm::mat2x4 p = x * m;
glm::mat2x4 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_ctr()
{
int Error(0);
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat2x4 m0(
glm::vec4(0, 1, 2, 3),
glm::vec4(4, 5, 6, 7));
glm::mat2x4 m1{0, 1, 2, 3, 4, 5, 6, 7};
glm::mat2x4 m2{
{0, 1, 2, 3},
{4, 5, 6, 7}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat2x4> v1{
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 1, 2, 3, 4, 5, 6, 7}
};
std::vector<glm::mat2x4> v2{
{
{ 0, 1, 2, 3},
{ 4, 5, 6, 7}
},
{
{ 0, 1, 2, 3},
{ 4, 5, 6, 7}
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_mat4x3.cpp | .cpp | 2,986 | 116 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_mat4x3.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat4x3.hpp>
#include <vector>
static int test_operators()
{
glm::mat4x3 l(1.0f);
glm::mat4x3 m(1.0f);
glm::vec4 u(1.0f);
glm::vec3 v(1.0f);
float x = 1.0f;
glm::vec3 a = m * u;
glm::vec4 b = v * m;
glm::mat4x3 n = x / m;
glm::mat4x3 o = m / x;
glm::mat4x3 p = x * m;
glm::mat4x3 q = m * x;
bool R = m != q;
bool S = m == l;
return (S && !R) ? 0 : 1;
}
int test_ctr()
{
int Error(0);
#if(GLM_HAS_INITIALIZER_LISTS)
glm::mat4x3 m0(
glm::vec3(0, 1, 2),
glm::vec3(3, 4, 5),
glm::vec3(6, 7, 8),
glm::vec3(9, 10, 11));
glm::mat4x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
glm::mat4x3 m2{
{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
{9, 10, 11}};
for(glm::length_t i = 0; i < m0.length(); ++i)
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
for(glm::length_t i = 0; i < m1.length(); ++i)
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
std::vector<glm::mat4x3> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
};
std::vector<glm::mat4x3> v2{
{
{ 0, 1, 2 },
{ 4, 5, 6 },
{ 8, 9, 10 },
{ 12, 13, 14 }
},
{
{ 0, 1, 2 },
{ 4, 5, 6 },
{ 8, 9, 10 },
{ 12, 13, 14 }
}
};
#endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error = 0;
Error += test_ctr();
Error += test_operators();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_setup_force_cxx98.cpp | .cpp | 1,736 | 43 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref test
/// @file test/core/core_setup_force_cxx98.cpp
/// @date 2014-11-15 / 2014-11-15
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_CXX98
#include <glm/glm.hpp>
#include <glm/ext.hpp>
int main()
{
int Error = 0;
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_type_float.cpp | .cpp | 2,130 | 63 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/core_type_float.cpp
/// @date 2008-08-31 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
int test_float_size()
{
return
sizeof(glm::float_t) != sizeof(glm::lowp_float) &&
sizeof(glm::float_t) != sizeof(glm::mediump_float) &&
sizeof(glm::float_t) != sizeof(glm::highp_float);
}
int test_float_precision()
{
return (
sizeof(glm::lowp_float) <= sizeof(glm::mediump_float) &&
sizeof(glm::mediump_float) <= sizeof(glm::highp_float)) ? 0 : 1;
}
int test_vec2()
{
return 0;
}
int main()
{
int Error = 0;
Error += test_float_size();
Error += test_float_precision();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/core/core_func_common.cpp | .cpp | 31,830 | 1,166 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/core/func_common.cpp
/// @date 2011-01-15 / 2011-09-13
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_EXPLICIT_CTOR
#include <glm/common.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtc/random.hpp>
#include <vector>
#include <cstdio>
#include <cmath>
#include <ctime>
namespace floor_
{
int test()
{
int Error(0);
{
float A(1.1f);
float B = glm::floor(A);
}
{
double A(1.1f);
double B = glm::floor(A);
}
{
glm::vec1 A(1.1f);
glm::vec1 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::vec1(1.0), 0.0001f)) ? 0 : 1;
}
{
glm::dvec1 A(1.1f);
glm::dvec1 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::dvec1(1.0), 0.0001)) ? 0 : 1;
}
{
glm::vec2 A(1.1f);
glm::vec2 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::vec2(1.0), 0.0001f)) ? 0 : 1;
}
{
glm::dvec2 A(1.1f);
glm::dvec2 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::dvec2(1.0), 0.0001)) ? 0 : 1;
}
{
glm::vec3 A(1.1f);
glm::vec3 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::vec3(1.0), 0.0001f)) ? 0 : 1;
}
{
glm::dvec3 A(1.1f);
glm::dvec3 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::dvec3(1.0), 0.0001)) ? 0 : 1;
}
{
glm::vec4 A(1.1f);
glm::vec4 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::vec4(1.0), 0.0001f)) ? 0 : 1;
}
{
glm::dvec4 A(1.1f);
glm::dvec4 B = glm::floor(A);
Error += glm::all(glm::epsilonEqual(B, glm::dvec4(1.0), 0.0001)) ? 0 : 1;
}
return Error;
}
}//namespace floor
namespace modf_
{
int test()
{
int Error(0);
{
float X(1.5f);
float I(0.0f);
float A = glm::modf(X, I);
Error += I == 1.0f ? 0 : 1;
Error += A == 0.5f ? 0 : 1;
}
{
glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f);
glm::vec4 I(0.0f);
glm::vec4 A = glm::modf(X, I);
Error += I == glm::vec4(1.0f) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1;
}
{
glm::dvec4 X(1.1, 1.2, 1.5, 1.7);
glm::dvec4 I(0.0);
glm::dvec4 A = glm::modf(X, I);
Error += I == glm::dvec4(1.0) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1;
}
{
double X(1.5);
double I(0.0);
double A = glm::modf(X, I);
Error += I == 1.0 ? 0 : 1;
Error += A == 0.5 ? 0 : 1;
}
return Error;
}
}//namespace modf
namespace mod_
{
int test()
{
int Error(0);
{
float A(3.0);
float B(2.0f);
float C = glm::mod(A, B);
Error += glm::abs(C - 1.0f) < 0.00001f ? 0 : 1;
}
{
glm::vec4 A(3.0);
float B(2.0f);
glm::vec4 C = glm::mod(A, B);
Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1;
}
{
glm::vec4 A(3.0);
glm::vec4 B(2.0f);
glm::vec4 C = glm::mod(A, B);
Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1;
}
return Error;
}
}//namespace mod_
namespace floatBitsToInt
{
int test()
{
int Error = 0;
{
float A = 1.0f;
int B = glm::floatBitsToInt(A);
float C = glm::intBitsToFloat(B);
int D = *(int*)&A;
Error += B == D ? 0 : 1;
Error += A == C ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::ivec2 B = glm::floatBitsToInt(A);
glm::vec2 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::ivec3 B = glm::floatBitsToInt(A);
glm::vec3 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += B.z == *(int*)&(A.z) ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::ivec4 B = glm::floatBitsToInt(A);
glm::vec4 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += B.z == *(int*)&(A.z) ? 0 : 1;
Error += B.w == *(int*)&(A.w) ? 0 : 1;
Error += A == C? 0 : 1;
}
return Error;
}
}//namespace floatBitsToInt
namespace floatBitsToUint
{
int test()
{
int Error = 0;
{
float A = 1.0f;
glm::uint B = glm::floatBitsToUint(A);
float C = glm::intBitsToFloat(B);
Error += B == *(glm::uint*)&A ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::uvec2 B = glm::floatBitsToUint(A);
glm::vec2 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += A == C ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::uvec3 B = glm::floatBitsToUint(A);
glm::vec3 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::uvec4 B = glm::floatBitsToUint(A);
glm::vec4 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1;
Error += A == C? 0 : 1;
}
return Error;
}
}//namespace floatBitsToUint
namespace min_
{
int test()
{
int Error = 0;
glm::vec1 A0 = glm::min(glm::vec1(1), glm::vec1(1));
glm::vec2 B0 = glm::min(glm::vec2(1), glm::vec2(1));
glm::vec2 B1 = glm::min(glm::vec2(1), 1.0f);
bool B2 = glm::all(glm::equal(B0, B1));
Error += B2 ? 0 : 1;
glm::vec3 C0 = glm::min(glm::vec3(1), glm::vec3(1));
glm::vec3 C1 = glm::min(glm::vec3(1), 1.0f);
bool C2 = glm::all(glm::equal(C0, C1));
Error += C2 ? 0 : 1;
glm::vec4 D0 = glm::min(glm::vec4(1), glm::vec4(1));
glm::vec4 D1 = glm::min(glm::vec4(1), 1.0f);
bool D2 = glm::all(glm::equal(D0, D1));
Error += D2 ? 0 : 1;
return Error;
}
}//namespace min_
namespace max_
{
int test()
{
int Error = 0;
glm::vec1 A0 = glm::max(glm::vec1(1), glm::vec1(1));
glm::vec2 B0 = glm::max(glm::vec2(1), glm::vec2(1));
glm::vec2 B1 = glm::max(glm::vec2(1), 1.0f);
bool B2 = glm::all(glm::equal(B0, B1));
Error += B2 ? 0 : 1;
glm::vec3 C0 = glm::max(glm::vec3(1), glm::vec3(1));
glm::vec3 C1 = glm::max(glm::vec3(1), 1.0f);
bool C2 = glm::all(glm::equal(C0, C1));
Error += C2 ? 0 : 1;
glm::vec4 D0 = glm::max(glm::vec4(1), glm::vec4(1));
glm::vec4 D1 = glm::max(glm::vec4(1), 1.0f);
bool D2 = glm::all(glm::equal(D0, D1));
Error += D2 ? 0 : 1;
return Error;
}
}//namespace max_
namespace clamp_
{
int test()
{
int Error = 0;
return Error;
}
}//namespace clamp_
namespace mix_
{
template <typename T, typename B>
struct entry
{
T x;
T y;
B a;
T Result;
};
entry<float, bool> TestBool[] =
{
{0.0f, 1.0f, false, 0.0f},
{0.0f, 1.0f, true, 1.0f},
{-1.0f, 1.0f, false, -1.0f},
{-1.0f, 1.0f, true, 1.0f}
};
entry<float, float> TestFloat[] =
{
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 1.0f, 1.0f},
{-1.0f, 1.0f, 0.0f, -1.0f},
{-1.0f, 1.0f, 1.0f, 1.0f}
};
entry<glm::vec2, bool> TestVec2Bool[] =
{
{glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)},
{glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)},
{glm::vec2(-1.0f), glm::vec2(1.0f), false, glm::vec2(-1.0f)},
{glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}
};
entry<glm::vec2, glm::bvec2> TestBVec2[] =
{
{glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)},
{glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
{glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(-1.0f)},
{glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
{glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)}
};
entry<glm::vec3, bool> TestVec3Bool[] =
{
{glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)},
{glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)},
{glm::vec3(-1.0f), glm::vec3(1.0f), false, glm::vec3(-1.0f)},
{glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}
};
entry<glm::vec3, glm::bvec3> TestBVec3[] =
{
{glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)},
{glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
{glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(-1.0f)},
{glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
{glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)}
};
entry<glm::vec4, bool> TestVec4Bool[] =
{
{glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)},
{glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)},
{glm::vec4(-1.0f), glm::vec4(1.0f), false, glm::vec4(-1.0f)},
{glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}
};
entry<glm::vec4, glm::bvec4> TestBVec4[] =
{
{glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(0.0f)},
{glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
{glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(-1.0f)},
{glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
{glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f), glm::bvec4(true, false, true, false), glm::vec4(5.0f, 2.0f, 7.0f, 4.0f)}
};
int test()
{
int Error = 0;
// Float with bool
{
for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(entry<float, bool>); ++i)
{
float Result = glm::mix(TestBool[i].x, TestBool[i].y, TestBool[i].a);
Error += glm::epsilonEqual(Result, TestBool[i].Result, glm::epsilon<float>()) ? 0 : 1;
}
}
// Float with float
{
for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(entry<float, float>); ++i)
{
float Result = glm::mix(TestFloat[i].x, TestFloat[i].y, TestFloat[i].a);
Error += glm::epsilonEqual(Result, TestFloat[i].Result, glm::epsilon<float>()) ? 0 : 1;
}
}
// vec2 with bool
{
for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(entry<glm::vec2, bool>); ++i)
{
glm::vec2 Result = glm::mix(TestVec2Bool[i].x, TestVec2Bool[i].y, TestVec2Bool[i].a);
Error += glm::epsilonEqual(Result.x, TestVec2Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.y, TestVec2Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
}
}
// vec2 with bvec2
{
for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(entry<glm::vec2, glm::bvec2>); ++i)
{
glm::vec2 Result = glm::mix(TestBVec2[i].x, TestBVec2[i].y, TestBVec2[i].a);
Error += glm::epsilonEqual(Result.x, TestBVec2[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.y, TestBVec2[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
}
}
// vec3 with bool
{
for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(entry<glm::vec3, bool>); ++i)
{
glm::vec3 Result = glm::mix(TestVec3Bool[i].x, TestVec3Bool[i].y, TestVec3Bool[i].a);
Error += glm::epsilonEqual(Result.x, TestVec3Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.y, TestVec3Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.z, TestVec3Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
}
}
// vec3 with bvec3
{
for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(entry<glm::vec3, glm::bvec3>); ++i)
{
glm::vec3 Result = glm::mix(TestBVec3[i].x, TestBVec3[i].y, TestBVec3[i].a);
Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.y, TestBVec3[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.z, TestBVec3[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
}
}
// vec4 with bool
{
for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(entry<glm::vec4, bool>); ++i)
{
glm::vec4 Result = glm::mix(TestVec4Bool[i].x, TestVec4Bool[i].y, TestVec4Bool[i].a);
Error += glm::epsilonEqual(Result.x, TestVec4Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.y, TestVec4Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.z, TestVec4Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.w, TestVec4Bool[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
}
}
// vec4 with bvec4
{
for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(entry<glm::vec4, glm::bvec4>); ++i)
{
glm::vec4 Result = glm::mix(TestBVec4[i].x, TestBVec4[i].y, TestBVec4[i].a);
Error += glm::epsilonEqual(Result.x, TestBVec4[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.y, TestBVec4[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.z, TestBVec4[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
Error += glm::epsilonEqual(Result.w, TestBVec4[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
}
}
return Error;
}
}//namespace mix_
namespace step_
{
template <typename EDGE, typename VEC>
struct entry
{
EDGE edge;
VEC x;
VEC result;
};
entry<float, glm::vec4> TestVec4Scalar [] =
{
{ 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
{ 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
{ 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) }
};
entry<glm::vec4, glm::vec4> TestVec4Vector [] =
{
{ glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) },
{ glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
{ glm::vec4( 2.0f, 3.0f, 4.0f, 5.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(0.0f) },
{ glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) }
};
int test()
{
int Error = 0;
// vec4 and float
{
for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(entry<float, glm::vec4>); ++i)
{
glm::vec4 Result = glm::step(TestVec4Scalar[i].edge, TestVec4Scalar[i].x);
Error += glm::all(glm::epsilonEqual(Result, TestVec4Scalar[i].result, glm::epsilon<float>())) ? 0 : 1;
}
}
// vec4 and vec4
{
for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(entry<glm::vec4, glm::vec4>); ++i)
{
glm::vec4 Result = glm::step(TestVec4Vector[i].edge, TestVec4Vector[i].x);
Error += glm::all(glm::epsilonEqual(Result, TestVec4Vector[i].result, glm::epsilon<float>())) ? 0 : 1;
}
}
return Error;
}
}//namespace step_
namespace round_
{
int test()
{
int Error = 0;
{
float A = glm::round(0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(0.5f);
Error += B == 1.0f ? 0 : 1;
float C = glm::round(1.0f);
Error += C == 1.0f ? 0 : 1;
float D = glm::round(0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(0.9f);
Error += E == 1.0f ? 0 : 1;
float F = glm::round(1.5f);
Error += F == 2.0f ? 0 : 1;
float G = glm::round(1.9f);
Error += G == 2.0f ? 0 : 1;
}
{
float A = glm::round(-0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(-0.5f);
Error += B == -1.0f ? 0 : 1;
float C = glm::round(-1.0f);
Error += C == -1.0f ? 0 : 1;
float D = glm::round(-0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(-0.9f);
Error += E == -1.0f ? 0 : 1;
float F = glm::round(-1.5f);
Error += F == -2.0f ? 0 : 1;
float G = glm::round(-1.9f);
Error += G == -2.0f ? 0 : 1;
}
return Error;
}
}//namespace round_
namespace roundEven
{
int test()
{
int Error = 0;
{
float A1 = glm::roundEven(-1.5f);
Error += glm::epsilonEqual(A1, -2.0f, 0.0001f) ? 0 : 1;
float A2 = glm::roundEven(1.5f);
Error += glm::epsilonEqual(A2, 2.0f, 0.0001f) ? 0 : 1;
float A5 = glm::roundEven(-2.5f);
Error += glm::epsilonEqual(A5, -2.0f, 0.0001f) ? 0 : 1;
float A6 = glm::roundEven(2.5f);
Error += glm::epsilonEqual(A6, 2.0f, 0.0001f) ? 0 : 1;
float A3 = glm::roundEven(-3.5f);
Error += glm::epsilonEqual(A3, -4.0f, 0.0001f) ? 0 : 1;
float A4 = glm::roundEven(3.5f);
Error += glm::epsilonEqual(A4, 4.0f, 0.0001f) ? 0 : 1;
float C7 = glm::roundEven(-4.5f);
Error += glm::epsilonEqual(C7, -4.0f, 0.0001f) ? 0 : 1;
float C8 = glm::roundEven(4.5f);
Error += glm::epsilonEqual(C8, 4.0f, 0.0001f) ? 0 : 1;
float C1 = glm::roundEven(-5.5f);
Error += glm::epsilonEqual(C1, -6.0f, 0.0001f) ? 0 : 1;
float C2 = glm::roundEven(5.5f);
Error += glm::epsilonEqual(C2, 6.0f, 0.0001f) ? 0 : 1;
float C3 = glm::roundEven(-6.5f);
Error += glm::epsilonEqual(C3, -6.0f, 0.0001f) ? 0 : 1;
float C4 = glm::roundEven(6.5f);
Error += glm::epsilonEqual(C4, 6.0f, 0.0001f) ? 0 : 1;
float C5 = glm::roundEven(-7.5f);
Error += glm::epsilonEqual(C5, -8.0f, 0.0001f) ? 0 : 1;
float C6 = glm::roundEven(7.5f);
Error += glm::epsilonEqual(C6, 8.0f, 0.0001f) ? 0 : 1;
Error += 0;
}
{
float A7 = glm::roundEven(-2.4f);
Error += glm::epsilonEqual(A7, -2.0f, 0.0001f) ? 0 : 1;
float A8 = glm::roundEven(2.4f);
Error += glm::epsilonEqual(A8, 2.0f, 0.0001f) ? 0 : 1;
float B1 = glm::roundEven(-2.6f);
Error += glm::epsilonEqual(B1, -3.0f, 0.0001f) ? 0 : 1;
float B2 = glm::roundEven(2.6f);
Error += glm::epsilonEqual(B2, 3.0f, 0.0001f) ? 0 : 1;
float B3 = glm::roundEven(-2.0f);
Error += glm::epsilonEqual(B3, -2.0f, 0.0001f) ? 0 : 1;
float B4 = glm::roundEven(2.0f);
Error += glm::epsilonEqual(B4, 2.0f, 0.0001f) ? 0 : 1;
Error += 0;
}
{
float A = glm::roundEven(0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::roundEven(0.5f);
Error += B == 0.0f ? 0 : 1;
float C = glm::roundEven(1.0f);
Error += C == 1.0f ? 0 : 1;
float D = glm::roundEven(0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::roundEven(0.9f);
Error += E == 1.0f ? 0 : 1;
float F = glm::roundEven(1.5f);
Error += F == 2.0f ? 0 : 1;
float G = glm::roundEven(1.9f);
Error += G == 2.0f ? 0 : 1;
}
{
float A = glm::roundEven(-0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::roundEven(-0.5f);
Error += B == -0.0f ? 0 : 1;
float C = glm::roundEven(-1.0f);
Error += C == -1.0f ? 0 : 1;
float D = glm::roundEven(-0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::roundEven(-0.9f);
Error += E == -1.0f ? 0 : 1;
float F = glm::roundEven(-1.5f);
Error += F == -2.0f ? 0 : 1;
float G = glm::roundEven(-1.9f);
Error += G == -2.0f ? 0 : 1;
}
{
float A = glm::roundEven(1.5f);
Error += A == 2.0f ? 0 : 1;
float B = glm::roundEven(2.5f);
Error += B == 2.0f ? 0 : 1;
float C = glm::roundEven(3.5f);
Error += C == 4.0f ? 0 : 1;
float D = glm::roundEven(4.5f);
Error += D == 4.0f ? 0 : 1;
float E = glm::roundEven(5.5f);
Error += E == 6.0f ? 0 : 1;
float F = glm::roundEven(6.5f);
Error += F == 6.0f ? 0 : 1;
float G = glm::roundEven(7.5f);
Error += G == 8.0f ? 0 : 1;
}
{
float A = glm::roundEven(-1.5f);
Error += A == -2.0f ? 0 : 1;
float B = glm::roundEven(-2.5f);
Error += B == -2.0f ? 0 : 1;
float C = glm::roundEven(-3.5f);
Error += C == -4.0f ? 0 : 1;
float D = glm::roundEven(-4.5f);
Error += D == -4.0f ? 0 : 1;
float E = glm::roundEven(-5.5f);
Error += E == -6.0f ? 0 : 1;
float F = glm::roundEven(-6.5f);
Error += F == -6.0f ? 0 : 1;
float G = glm::roundEven(-7.5f);
Error += G == -8.0f ? 0 : 1;
}
return Error;
}
}//namespace roundEven
namespace isnan_
{
int test()
{
int Error = 0;
float Zero_f = 0.0;
double Zero_d = 0.0;
{
Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1;
}
{
Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
}
return Error;
}
}//namespace isnan_
namespace isinf_
{
int test()
{
int Error = 0;
float Zero_f = 0.0;
double Zero_d = 0.0;
{
Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
}
{
Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
}
return Error;
}
}//namespace isinf_
namespace sign
{
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_if(genFIType x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genFIType>::is_iec559 ||
(std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer), "'sign' only accept signed inputs");
genFIType result;
if(x > genFIType(0))
result = genFIType(1);
else if(x < genFIType(0))
result = genFIType(-1);
else
result = genFIType(0);
return result;
}
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_alu1(genFIType x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
"'sign' only accept integer inputs");
return (x >> 31) | ((unsigned)-x >> 31);
}
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_alu2(genFIType x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
"'sign' only accept integer inputs");
return -((unsigned)x >> 31) | (-(unsigned)x >> 31);
}
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_sub(genFIType x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
"'sign' only accept integer inputs");
return ((unsigned)-x >> 31) - ((unsigned)x >> 31);
}
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign_cmp(genFIType x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer,
"'sign' only accept integer inputs");
return (x > 0) - (x < 0);
}
template <typename genType>
struct type
{
genType Value;
genType Return;
};
int test_int32()
{
type<glm::int32> const Data[] =
{
{ std::numeric_limits<glm::int32>::max(), 1},
{ std::numeric_limits<glm::int32>::min(), -1},
{ 0, 0},
{ 1, 1},
{ 2, 1},
{ 3, 1},
{-1,-1},
{-2,-1},
{-3,-1}
};
int Error = 0;
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = glm::sign(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = sign_cmp(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = sign_if(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = sign_alu1(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::int32>); ++i)
{
glm::int32 Result = sign_alu2(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_i32vec4()
{
type<glm::i32vec4> const Data[] =
{
{glm::i32vec4( 1), glm::i32vec4( 1)},
{glm::i32vec4( 0), glm::i32vec4( 0)},
{glm::i32vec4( 2), glm::i32vec4( 1)},
{glm::i32vec4( 3), glm::i32vec4( 1)},
{glm::i32vec4(-1), glm::i32vec4(-1)},
{glm::i32vec4(-2), glm::i32vec4(-1)},
{glm::i32vec4(-3), glm::i32vec4(-1)}
};
int Error = 0;
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<glm::i32vec4>); ++i)
{
glm::i32vec4 Result = glm::sign(Data[i].Value);
Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1;
}
return Error;
}
int test()
{
int Error = 0;
Error += test_int32();
Error += test_i32vec4();
return Error;
}
int perf_rand()
{
int Error = 0;
std::size_t const Count = 100000000;
std::vector<glm::int32> Input, Output;
Input.resize(Count);
Output.resize(Count);
for(std::size_t i = 0; i < Count; ++i)
Input[i] = static_cast<glm::int32>(glm::linearRand(-65536.f, 65536.f));
std::clock_t Timestamp0 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_cmp(Input[i]);
std::clock_t Timestamp1 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_if(Input[i]);
std::clock_t Timestamp2 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_alu1(Input[i]);
std::clock_t Timestamp3 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_alu2(Input[i]);
std::clock_t Timestamp4 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_sub(Input[i]);
std::clock_t Timestamp5 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = glm::sign(Input[i]);
std::clock_t Timestamp6 = std::clock();
std::printf("sign_cmp(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp1 - Timestamp0));
std::printf("sign_if(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp2 - Timestamp1));
std::printf("sign_alu1(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp3 - Timestamp2));
std::printf("sign_alu2(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp4 - Timestamp3));
std::printf("sign_sub(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp5 - Timestamp4));
std::printf("glm::sign(rand) Time %d clocks\n", static_cast<unsigned int>(Timestamp6 - Timestamp5));
return Error;
}
int perf_linear()
{
int Error = 0;
std::size_t const Count = 10000000;
std::vector<glm::int32> Input, Output;
Input.resize(Count);
Output.resize(Count);
for(std::size_t i = 0; i < Count; ++i)
Input[i] = static_cast<glm::int32>(i);
std::clock_t Timestamp0 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_cmp(Input[i]);
std::clock_t Timestamp1 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_if(Input[i]);
std::clock_t Timestamp2 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_alu1(Input[i]);
std::clock_t Timestamp3 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_alu2(Input[i]);
std::clock_t Timestamp4 = std::clock();
for(std::size_t i = 0; i < Count; ++i)
Output[i] = sign_sub(Input[i]);
std::clock_t Timestamp5 = std::clock();
std::printf("sign_cmp(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp1 - Timestamp0));
std::printf("sign_if(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp2 - Timestamp1));
std::printf("sign_alu1(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp3 - Timestamp2));
std::printf("sign_alu2(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp4 - Timestamp3));
std::printf("sign_sub(linear) Time %d clocks\n", static_cast<unsigned int>(Timestamp5 - Timestamp4));
return Error;
}
int perf_linear_cal()
{
int Error = 0;
glm::uint32 const Count = 10000000;
std::clock_t Timestamp0 = std::clock();
glm::int32 Sum = 0;
for(glm::int32 i = 1; i < Count; ++i)
Sum += sign_cmp(i);
std::clock_t Timestamp1 = std::clock();
for(glm::int32 i = 1; i < Count; ++i)
Sum += sign_if(i);
std::clock_t Timestamp2 = std::clock();
for(glm::int32 i = 1; i < Count; ++i)
Sum += sign_alu1(i);
std::clock_t Timestamp3 = std::clock();
for(glm::int32 i = 1; i < Count; ++i)
Sum += sign_alu2(i);
std::clock_t Timestamp4 = std::clock();
for(glm::int32 i = 1; i < Count; ++i)
Sum += sign_sub(i);
std::clock_t Timestamp5 = std::clock();
std::printf("Sum %d\n", static_cast<unsigned int>(Sum));
std::printf("sign_cmp(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp1 - Timestamp0));
std::printf("sign_if(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp2 - Timestamp1));
std::printf("sign_alu1(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp3 - Timestamp2));
std::printf("sign_alu2(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp4 - Timestamp3));
std::printf("sign_sub(linear_cal) Time %d clocks\n", static_cast<unsigned int>(Timestamp5 - Timestamp4));
return Error;
}
int perf()
{
int Error(0);
Error += perf_linear_cal();
Error += perf_linear();
Error += perf_rand();
return Error;
}
}//namespace sign
int main()
{
int Error(0);
Error += sign::test();
Error += floor_::test();
Error += mod_::test();
Error += modf_::test();
Error += floatBitsToInt::test();
Error += floatBitsToUint::test();
Error += step_::test();
Error += max_::test();
Error += min_::test();
Error += mix_::test();
Error += round_::test();
Error += roundEven::test();
Error += isnan_::test();
Error += isinf_::test();
# ifdef NDEBUG
Error += sign::perf();
# endif
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_random.cpp | .cpp | 11,201 | 409 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_random.cpp
/// @date 2011-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/random.hpp>
#include <glm/gtc/epsilon.hpp>
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
# include <array>
#endif
int test_linearRand()
{
int Error = 0;
glm::int32 const Min = 16;
glm::int32 const Max = 32;
{
glm::u8vec2 AMin(std::numeric_limits<glm::u8>::max());
glm::u8vec2 AMax(std::numeric_limits<glm::u8>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u8vec2 A = glm::linearRand(glm::u8vec2(Min), glm::u8vec2(Max));
AMin = glm::min(AMin, A);
AMax = glm::max(AMax, A);
if(!glm::all(glm::lessThanEqual(A, glm::u8vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(A, glm::u8vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(AMin, glm::u8vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(AMax, glm::u8vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::u16vec2 BMin(std::numeric_limits<glm::u16>::max());
glm::u16vec2 BMax(std::numeric_limits<glm::u16>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u16vec2 B = glm::linearRand(glm::u16vec2(Min), glm::u16vec2(Max));
BMin = glm::min(BMin, B);
BMax = glm::max(BMax, B);
if(!glm::all(glm::lessThanEqual(B, glm::u16vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(B, glm::u16vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(BMin, glm::u16vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(BMax, glm::u16vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::u32vec2 CMin(std::numeric_limits<glm::u32>::max());
glm::u32vec2 CMax(std::numeric_limits<glm::u32>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u32vec2 C = glm::linearRand(glm::u32vec2(Min), glm::u32vec2(Max));
CMin = glm::min(CMin, C);
CMax = glm::max(CMax, C);
if(!glm::all(glm::lessThanEqual(C, glm::u32vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(C, glm::u32vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(CMin, glm::u32vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(CMax, glm::u32vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::u64vec2 DMin(std::numeric_limits<glm::u64>::max());
glm::u64vec2 DMax(std::numeric_limits<glm::u64>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u64vec2 D = glm::linearRand(glm::u64vec2(Min), glm::u64vec2(Max));
DMin = glm::min(DMin, D);
DMax = glm::max(DMax, D);
if(!glm::all(glm::lessThanEqual(D, glm::u64vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(D, glm::u64vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(DMin, glm::u64vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(DMax, glm::u64vec2(Max))) ? 0 : 1;
assert(!Error);
}
}
{
glm::i8vec2 AMin(std::numeric_limits<glm::i8>::max());
glm::i8vec2 AMax(std::numeric_limits<glm::i8>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i8vec2 A = glm::linearRand(glm::i8vec2(Min), glm::i8vec2(Max));
AMin = glm::min(AMin, A);
AMax = glm::max(AMax, A);
if(!glm::all(glm::lessThanEqual(A, glm::i8vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(A, glm::i8vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(AMin, glm::i8vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(AMax, glm::i8vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::i16vec2 BMin(std::numeric_limits<glm::i16>::max());
glm::i16vec2 BMax(std::numeric_limits<glm::i16>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i16vec2 B = glm::linearRand(glm::i16vec2(Min), glm::i16vec2(Max));
BMin = glm::min(BMin, B);
BMax = glm::max(BMax, B);
if(!glm::all(glm::lessThanEqual(B, glm::i16vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(B, glm::i16vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(BMin, glm::i16vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(BMax, glm::i16vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::i32vec2 CMin(std::numeric_limits<glm::i32>::max());
glm::i32vec2 CMax(std::numeric_limits<glm::i32>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i32vec2 C = glm::linearRand(glm::i32vec2(Min), glm::i32vec2(Max));
CMin = glm::min(CMin, C);
CMax = glm::max(CMax, C);
if(!glm::all(glm::lessThanEqual(C, glm::i32vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(C, glm::i32vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(CMin, glm::i32vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(CMax, glm::i32vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::i64vec2 DMin(std::numeric_limits<glm::i64>::max());
glm::i64vec2 DMax(std::numeric_limits<glm::i64>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i64vec2 D = glm::linearRand(glm::i64vec2(Min), glm::i64vec2(Max));
DMin = glm::min(DMin, D);
DMax = glm::max(DMax, D);
if(!glm::all(glm::lessThanEqual(D, glm::i64vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(D, glm::i64vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(DMin, glm::i64vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(DMax, glm::i64vec2(Max))) ? 0 : 1;
assert(!Error);
}
}
for(std::size_t i = 0; i < 100000; ++i)
{
glm::f32vec2 const A(glm::linearRand(glm::f32vec2(static_cast<float>(Min)), glm::f32vec2(static_cast<float>(Max))));
if(!glm::all(glm::lessThanEqual(A, glm::f32vec2(static_cast<float>(Max)))))
++Error;
if(!glm::all(glm::greaterThanEqual(A, glm::f32vec2(static_cast<float>(Min)))))
++Error;
glm::f64vec2 const B(glm::linearRand(glm::f64vec2(Min), glm::f64vec2(Max)));
if(!glm::all(glm::lessThanEqual(B, glm::f64vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(B, glm::f64vec2(Min))))
++Error;
assert(!Error);
}
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::linearRand(-1.0f, 1.0f);
ResultDouble += glm::linearRand(-1.0, 1.0);
}
Error += glm::epsilonEqual(ResultFloat, 0.0f, 0.0001f);
Error += glm::epsilonEqual(ResultDouble, 0.0, 0.0001);
assert(!Error);
}
return Error;
}
int test_circularRand()
{
int Error = 0;
{
std::size_t Max = 100000;
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
double Radius = 2.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloat += glm::length(glm::circularRand(1.0f));
ResultDouble += glm::length(glm::circularRand(Radius));
}
Error += glm::epsilonEqual(ResultFloat, float(Max), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_sphericalRand()
{
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::sphericalRand(1.0f));
ResultDoubleA += glm::length(glm::sphericalRand(1.0));
ResultFloatB += glm::length(glm::sphericalRand(2.0f));
ResultDoubleB += glm::length(glm::sphericalRand(2.0));
ResultFloatC += glm::length(glm::sphericalRand(3.0f));
ResultDoubleC += glm::length(glm::sphericalRand(3.0));
}
Error += glm::epsilonEqual(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_diskRand()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::length(glm::diskRand(2.0f));
ResultDouble += glm::length(glm::diskRand(2.0));
}
Error += ResultFloat < 200000.f ? 0 : 1;
Error += ResultDouble < 200000.0 ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_ballRand()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::length(glm::ballRand(2.0f));
ResultDouble += glm::length(glm::ballRand(2.0));
}
Error += ResultFloat < 200000.f ? 0 : 1;
Error += ResultDouble < 200000.0 ? 0 : 1;
assert(!Error);
}
return Error;
}
/*
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
int test_grid()
{
int Error = 0;
typedef std::array<int, 8> colors;
typedef std::array<int, 8 * 8> grid;
grid Grid;
colors Colors;
grid GridBest;
colors ColorsBest;
while(true)
{
for(std::size_t i = 0; i < Grid.size(); ++i)
Grid[i] = int(glm::linearRand(0.0, 8.0 * 8.0 * 8.0 - 1.0) / 64.0);
for(std::size_t i = 0; i < Grid.size(); ++i)
++Colors[Grid[i]];
bool Exit = true;
for(std::size_t i = 0; i < Colors.size(); ++i)
{
if(Colors[i] == 8)
continue;
Exit = false;
break;
}
if(Exit == true)
break;
}
return Error;
}
#endif
*/
int main()
{
int Error = 0;
Error += test_linearRand();
Error += test_circularRand();
Error += test_sphericalRand();
Error += test_diskRand();
Error += test_ballRand();
/*
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
Error += test_grid();
#endif
*/
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_ulp.cpp | .cpp | 3,218 | 128 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_ulp.cpp
/// @date 2011-04-26 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/ulp.hpp>
#include <limits>
int test_ulp_float_dist()
{
int Error = 0;
float A = 1.0f;
float B = glm::next_float(A);
Error += A != B ? 0 : 1;
float C = glm::prev_float(B);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == 1 ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
return Error;
}
int test_ulp_float_step()
{
int Error = 0;
float A = 1.0f;
for(int i = 10; i < 1000; i *= 10)
{
float B = glm::next_float(A, i);
Error += A != B ? 0 : 1;
float C = glm::prev_float(B, i);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == i ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
}
return Error;
}
int test_ulp_double_dist()
{
int Error = 0;
double A = 1.0;
double B = glm::next_float(A);
Error += A != B ? 0 : 1;
double C = glm::prev_float(B);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == 1 ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
return Error;
}
int test_ulp_double_step()
{
int Error = 0;
double A = 1.0;
for(int i = 10; i < 1000; i *= 10)
{
double B = glm::next_float(A, i);
Error += A != B ? 0 : 1;
double C = glm::prev_float(B, i);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == i ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
}
return Error;
}
int main()
{
int Error = 0;
Error += test_ulp_float_dist();
Error += test_ulp_float_step();
Error += test_ulp_double_dist();
Error += test_ulp_double_step();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_reciprocal.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/gtc/gtc_reciprocal.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/reciprocal.hpp>
#include <ctime>
int main()
{
return 0;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_vec1.cpp | .cpp | 1,665 | 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/gtc/gtc_vec1.cpp
/// @date 2014-10-11 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/vec1.hpp>
int main()
{
int Error = 0;
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_integer.cpp | .cpp | 7,074 | 284 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_integer.cpp
/// @date 2014-11-17 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_INLINE
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/integer.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtx/type_aligned.hpp>
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <ctime>
#include <cstdio>
#include <vector>
namespace log2_
{
int test()
{
int Error = 0;
int A0 = static_cast<int>(glm::log2(16.f));
glm::ivec1 B0(glm::log2(glm::vec1(16.f)));
glm::ivec2 C0(glm::log2(glm::vec2(16.f)));
glm::ivec3 D0(glm::log2(glm::vec3(16.f)));
glm::ivec4 E0(glm::log2(glm::vec4(16.f)));
int A1 = glm::log2(int(16));
glm::ivec1 B1 = glm::log2(glm::ivec1(16));
glm::ivec2 C1 = glm::log2(glm::ivec2(16));
glm::ivec3 D1 = glm::log2(glm::ivec3(16));
glm::ivec4 E1 = glm::log2(glm::ivec4(16));
Error += A0 == A1 ? 0 : 1;
Error += glm::all(glm::equal(B0, B1)) ? 0 : 1;
Error += glm::all(glm::equal(C0, C1)) ? 0 : 1;
Error += glm::all(glm::equal(D0, D1)) ? 0 : 1;
Error += glm::all(glm::equal(E0, E1)) ? 0 : 1;
glm::uint64 A2 = glm::log2(glm::uint64(16));
glm::u64vec1 B2 = glm::log2(glm::u64vec1(16));
glm::u64vec2 C2 = glm::log2(glm::u64vec2(16));
glm::u64vec3 D2 = glm::log2(glm::u64vec3(16));
glm::u64vec4 E2 = glm::log2(glm::u64vec4(16));
Error += A2 == glm::uint64(4) ? 0 : 1;
Error += glm::all(glm::equal(B2, glm::u64vec1(4))) ? 0 : 1;
Error += glm::all(glm::equal(C2, glm::u64vec2(4))) ? 0 : 1;
Error += glm::all(glm::equal(D2, glm::u64vec3(4))) ? 0 : 1;
Error += glm::all(glm::equal(E2, glm::u64vec4(4))) ? 0 : 1;
return Error;
}
int perf()
{
int Error = 0;
std::size_t const Count(100000000);
{
std::vector<int> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(int i = 0; i < static_cast<int>(Count); ++i)
Result[i] = glm::log2(static_cast<int>(i));
std::clock_t End = clock();
printf("glm::log2<int>: %d clocks\n", End - Begin);
}
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(int i = 0; i < static_cast<int>(Count); ++i)
Result[i] = glm::log2(glm::ivec4(i));
std::clock_t End = clock();
printf("glm::log2<ivec4>: %d clocks\n", End - Begin);
}
# if GLM_HAS_BITSCAN_WINDOWS
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
{
glm::tvec4<unsigned long, glm::defaultp> Tmp(glm::uninitialize);
_BitScanReverse(&Tmp.x, i);
_BitScanReverse(&Tmp.y, i);
_BitScanReverse(&Tmp.z, i);
_BitScanReverse(&Tmp.w, i);
Result[i] = glm::ivec4(Tmp);
}
std::clock_t End = clock();
printf("glm::log2<ivec4> inlined: %d clocks\n", End - Begin);
}
{
std::vector<glm::tvec4<unsigned long, glm::defaultp> > Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
{
_BitScanReverse(&Result[i].x, i);
_BitScanReverse(&Result[i].y, i);
_BitScanReverse(&Result[i].z, i);
_BitScanReverse(&Result[i].w, i);
}
std::clock_t End = clock();
printf("glm::log2<ivec4> inlined no cast: %d clocks\n", End - Begin);
}
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
{
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].x), i);
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].y), i);
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].z), i);
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].w), i);
}
std::clock_t End = clock();
printf("glm::log2<ivec4> reinterpret: %d clocks\n", End - Begin);
}
# endif//GLM_HAS_BITSCAN_WINDOWS
{
std::vector<float> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
Result[i] = glm::log2(static_cast<float>(i));
std::clock_t End = clock();
printf("glm::log2<float>: %d clocks\n", End - Begin);
}
{
std::vector<glm::vec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(int i = 0; i < static_cast<int>(Count); ++i)
Result[i] = glm::log2(glm::vec4(i));
std::clock_t End = clock();
printf("glm::log2<vec4>: %d clocks\n", End - Begin);
}
return Error;
}
}//namespace log2_
namespace mod_
{
int test()
{
int Error(0);
{
float A(3.0);
float B(2.0f);
float C = glm::mod(A, B);
Error += glm::abs(C - 1.0f) < 0.00001f ? 0 : 1;
}
{
glm::vec4 A(3.0);
float B(2.0f);
glm::vec4 C = glm::mod(A, B);
Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1;
}
{
glm::vec4 A(3.0);
glm::vec4 B(2.0f);
glm::vec4 C = glm::mod(A, B);
Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1;
}
{
int A(3);
int B(2);
int C = glm::mod(A, B);
Error += C == 1 ? 0 : 1;
}
{
glm::ivec4 A(3);
int B(2);
glm::ivec4 C = glm::mod(A, B);
Error += glm::all(glm::equal(C, glm::ivec4(1))) ? 0 : 1;
}
{
glm::ivec4 A(3);
glm::ivec4 B(2);
glm::ivec4 C = glm::mod(A, B);
Error += glm::all(glm::equal(C, glm::ivec4(1))) ? 0 : 1;
}
return Error;
}
}//namespace mod_
int main()
{
int Error(0);
Error += ::log2_::test();
Error += ::mod_::test();
# ifdef NDEBUG
Error += ::log2_::perf();
# endif//NDEBUG
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_packing.cpp | .cpp | 12,345 | 534 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_packing.cpp
/// @date 2013-08-09 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/packing.hpp>
#include <glm/gtc/epsilon.hpp>
#include <cstdio>
#include <vector>
void print_bits(float const & s)
{
union
{
float f;
unsigned int i;
} uif;
uif.f = s;
printf("f32: ");
for(std::size_t j = sizeof(s) * 8; j > 0; --j)
{
if(j == 23 || j == 31)
printf(" ");
printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0);
}
}
void print_10bits(glm::uint const & s)
{
printf("10b: ");
for(std::size_t j = 10; j > 0; --j)
{
if(j == 5)
printf(" ");
printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
}
}
void print_11bits(glm::uint const & s)
{
printf("11b: ");
for(std::size_t j = 11; j > 0; --j)
{
if(j == 6)
printf(" ");
printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
}
}
void print_value(float const & s)
{
printf("%2.5f, ", s);
print_bits(s);
printf(", ");
// print_11bits(detail::floatTo11bit(s));
// printf(", ");
// print_10bits(detail::floatTo10bit(s));
printf("\n");
}
int test_Half1x16()
{
int Error = 0;
std::vector<float> Tests;
Tests.push_back(0.0f);
Tests.push_back(1.0f);
Tests.push_back(-1.0f);
Tests.push_back(2.0f);
Tests.push_back(-2.0f);
Tests.push_back(1.9f);
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
float v0 = glm::unpackHalf1x16(p0);
glm::uint32 p1 = glm::packHalf1x16(v0);
float v1 = glm::unpackHalf1x16(p1);
Error += (v0 == v1) ? 0 : 1;
}
return Error;
}
int test_Half4x16()
{
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(-0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
glm::vec4 v0 = glm::unpackHalf4x16(p0);
glm::uint64 p1 = glm::packHalf4x16(v0);
glm::vec4 v1 = glm::unpackHalf4x16(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_I3x10_1x2()
{
int Error = 0;
std::vector<glm::ivec4> Tests;
Tests.push_back(glm::ivec4(0));
Tests.push_back(glm::ivec4(1));
Tests.push_back(glm::ivec4(-1));
Tests.push_back(glm::ivec4(2));
Tests.push_back(glm::ivec4(-2));
Tests.push_back(glm::ivec4(3));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
glm::uint32 p1 = glm::packI3x10_1x2(v0);
glm::ivec4 v1 = glm::unpackI3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_U3x10_1x2()
{
int Error = 0;
std::vector<glm::uvec4> Tests;
Tests.push_back(glm::uvec4(0));
Tests.push_back(glm::uvec4(1));
Tests.push_back(glm::uvec4(2));
Tests.push_back(glm::uvec4(3));
Tests.push_back(glm::uvec4(4));
Tests.push_back(glm::uvec4(5));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
glm::uint32 p1 = glm::packU3x10_1x2(v0);
glm::uvec4 v1 = glm::unpackU3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_Snorm3x10_1x2()
{
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_Unorm3x10_1x2()
{
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_F2x11_1x10()
{
int Error = 0;
std::vector<glm::vec3> Tests;
Tests.push_back(glm::vec3(1.0f));
Tests.push_back(glm::vec3(0.0f));
Tests.push_back(glm::vec3(2.0f));
Tests.push_back(glm::vec3(0.1f));
Tests.push_back(glm::vec3(0.5f));
Tests.push_back(glm::vec3(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
glm::uint32 p1 = glm::packF2x11_1x10(v0);
glm::vec3 v1 = glm::unpackF2x11_1x10(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_packUnorm1x16()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1(1.0f));
A.push_back(glm::vec1(0.5f));
A.push_back(glm::vec1(0.1f));
A.push_back(glm::vec1(0.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint32 C = glm::packUnorm1x16(B.x);
glm::vec1 D(glm::unpackUnorm1x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm1x16()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1( 1.0f));
A.push_back(glm::vec1( 0.0f));
A.push_back(glm::vec1(-0.5f));
A.push_back(glm::vec1(-0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint32 C = glm::packSnorm1x16(B.x);
glm::vec1 D(glm::unpackSnorm1x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
}
return Error;
}
int test_packUnorm2x16()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2(1.0f, 0.0f));
A.push_back(glm::vec2(0.5f, 0.7f));
A.push_back(glm::vec2(0.1f, 0.2f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint32 C = glm::packUnorm2x16(B);
glm::vec2 D = glm::unpackUnorm2x16(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm2x16()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2( 1.0f, 0.0f));
A.push_back(glm::vec2(-0.5f,-0.7f));
A.push_back(glm::vec2(-0.1f, 0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint32 C = glm::packSnorm2x16(B);
glm::vec2 D = glm::unpackSnorm2x16(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packUnorm4x16()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4(1.0f));
A.push_back(glm::vec4(0.5f));
A.push_back(glm::vec4(0.1f));
A.push_back(glm::vec4(0.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint64 C = glm::packUnorm4x16(B);
glm::vec4 D(glm::unpackUnorm4x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm4x16()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4( 1.0f, 0.0f, -0.5f, 0.5f));
A.push_back(glm::vec4(-0.3f,-0.7f, 0.3f, 0.7f));
A.push_back(glm::vec4(-0.1f, 0.1f, -0.2f, 0.2f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint64 C = glm::packSnorm4x16(B);
glm::vec4 D(glm::unpackSnorm4x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packUnorm1x8()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1(1.0f));
A.push_back(glm::vec1(0.5f));
A.push_back(glm::vec1(0.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint16 C = glm::packUnorm1x8(B.x);
glm::vec1 D(glm::unpackUnorm1x8(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm1x8()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1( 1.0f));
A.push_back(glm::vec1(-0.7f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint16 C = glm::packSnorm1x8(B.x);
glm::vec1 D(glm::unpackSnorm1x8(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
}
return Error;
}
int test_packUnorm2x8()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2(1.0f, 0.7f));
A.push_back(glm::vec2(0.5f, 0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint16 C = glm::packUnorm2x8(B);
glm::vec2 D = glm::unpackUnorm2x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm2x8()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2( 1.0f, 0.0f));
A.push_back(glm::vec2(-0.7f,-0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint16 C = glm::packSnorm2x8(B);
glm::vec2 D = glm::unpackSnorm2x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
}
return Error;
}
int test_packUnorm4x8()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f));
A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint32 C = glm::packUnorm4x8(B);
glm::vec4 D = glm::unpackUnorm4x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm4x8()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4( 1.0f, 0.0f,-0.5f,-1.0f));
A.push_back(glm::vec4(-0.7f,-0.1f, 0.1f, 0.7f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint32 C = glm::packSnorm4x8(B);
glm::vec4 D = glm::unpackSnorm4x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int main()
{
int Error(0);
Error += test_packSnorm1x16();
Error += test_packSnorm2x16();
Error += test_packSnorm4x16();
Error += test_packSnorm1x8();
Error += test_packSnorm2x8();
Error += test_packSnorm4x8();
Error += test_packUnorm1x16();
Error += test_packUnorm2x16();
Error += test_packUnorm4x16();
Error += test_packUnorm1x8();
Error += test_packUnorm2x8();
Error += test_packUnorm4x8();
Error += test_F2x11_1x10();
Error += test_Snorm3x10_1x2();
Error += test_Unorm3x10_1x2();
Error += test_I3x10_1x2();
Error += test_U3x10_1x2();
Error += test_Half1x16();
Error += test_U3x10_1x2();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_matrix_inverse.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/gtc/gtc_matrix_inverse.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_inverse.hpp>
int main()
{
int Error = 0;
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_noise.cpp | .cpp | 7,684 | 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/gtc/gtc_noise.cpp
/// @date 2011-04-21 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/noise.hpp>
#include <gli/gli.hpp>
#include <gli/gtx/loader.hpp>
int test_simplex()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex4d_256.dds");
}
return 0;
}
int test_perlin()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin4d_256.dds");
}
return 0;
}
int test_perlin_pedioric()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f), glm::vec2(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f), glm::vec3(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f), glm::vec4(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_4d_256.dds");
}
return 0;
}
int main()
{
int Error = 0;
Error += test_simplex();
Error += test_perlin();
Error += test_perlin_pedioric();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_type_ptr.cpp | .cpp | 6,971 | 284 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_type_ptr.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_ptr.hpp>
int test_value_ptr_vec()
{
int Error = 0;
{
glm::vec2 v(1.0);
float * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec3 v(1.0);
float * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec4 v(1.0);
float * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec2 v(1.0);
double * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec3 v(1.0);
double * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec4 v(1.0);
double * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
return Error;
}
int test_value_ptr_vec_const()
{
int Error = 0;
{
glm::vec2 const v(1.0);
float const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec3 const v(1.0);
float const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec4 const v(1.0);
float const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec2 const v(1.0);
double const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec3 const v(1.0);
double const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec4 const v(1.0);
double const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
return Error;
}
int test_value_ptr_mat()
{
int Error = 0;
{
glm::mat2x2 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x3 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x4 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x2 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x3 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x4 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x2 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x3 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x4 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
return Error;
}
int test_value_ptr_mat_const()
{
int Error = 0;
{
glm::mat2x2 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x3 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x4 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x2 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x3 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x4 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x2 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x3 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x4 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
return Error;
}
int test_make_pointer_mat()
{
int Error = 0;
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
double ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
glm::mat2x2 Mat2x2A = glm::make_mat2x2(ArrayA);
glm::mat2x3 Mat2x3A = glm::make_mat2x3(ArrayA);
glm::mat2x4 Mat2x4A = glm::make_mat2x4(ArrayA);
glm::mat3x2 Mat3x2A = glm::make_mat3x2(ArrayA);
glm::mat3x3 Mat3x3A = glm::make_mat3x3(ArrayA);
glm::mat3x4 Mat3x4A = glm::make_mat3x4(ArrayA);
glm::mat4x2 Mat4x2A = glm::make_mat4x2(ArrayA);
glm::mat4x3 Mat4x3A = glm::make_mat4x3(ArrayA);
glm::mat4x4 Mat4x4A = glm::make_mat4x4(ArrayA);
glm::dmat2x2 Mat2x2B = glm::make_mat2x2(ArrayB);
glm::dmat2x3 Mat2x3B = glm::make_mat2x3(ArrayB);
glm::dmat2x4 Mat2x4B = glm::make_mat2x4(ArrayB);
glm::dmat3x2 Mat3x2B = glm::make_mat3x2(ArrayB);
glm::dmat3x3 Mat3x3B = glm::make_mat3x3(ArrayB);
glm::dmat3x4 Mat3x4B = glm::make_mat3x4(ArrayB);
glm::dmat4x2 Mat4x2B = glm::make_mat4x2(ArrayB);
glm::dmat4x3 Mat4x3B = glm::make_mat4x3(ArrayB);
glm::dmat4x4 Mat4x4B = glm::make_mat4x4(ArrayB);
return Error;
}
int test_make_pointer_vec()
{
int Error = 0;
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
bool ArrayC[] = {true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false};
glm::vec2 Vec2A = glm::make_vec2(ArrayA);
glm::vec3 Vec3A = glm::make_vec3(ArrayA);
glm::vec4 Vec4A = glm::make_vec4(ArrayA);
glm::ivec2 Vec2B = glm::make_vec2(ArrayB);
glm::ivec3 Vec3B = glm::make_vec3(ArrayB);
glm::ivec4 Vec4B = glm::make_vec4(ArrayB);
glm::bvec2 Vec2C = glm::make_vec2(ArrayC);
glm::bvec3 Vec3C = glm::make_vec3(ArrayC);
glm::bvec4 Vec4C = glm::make_vec4(ArrayC);
return Error;
}
int main()
{
int Error = 0;
Error += test_make_pointer_vec();
Error += test_make_pointer_mat();
Error += test_value_ptr_vec();
Error += test_value_ptr_vec_const();
Error += test_value_ptr_mat();
Error += test_value_ptr_mat_const();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_user_defined_types.cpp | .cpp | 753 | 31 | ///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-16
// Updated : 2011-05-27
// Licence : This source is under MIT licence
// File : test/gtc/type_ptr.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_RADIANS
#include <glm/gtc/user_defined_type.hpp>
int test_make_pointer_vec()
{
int Error = 0;
glm::func();
//func();
return Error;
}
int main()
{
int Error = 0;
Error += test_make_pointer_vec();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_constants.cpp | .cpp | 1,977 | 60 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_constants.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/constants.hpp>
int test_epsilon()
{
int Error(0);
{
float Test = glm::epsilon<float>();
}
{
double Test = glm::epsilon<double>();
}
return Error;
}
int main()
{
int Error(0);
//float MinHalf = 0.0f;
//while (glm::half(MinHalf) == glm::half(0.0f))
// MinHalf += std::numeric_limits<float>::epsilon();
Error += test_epsilon();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_type_precision.cpp | .cpp | 28,856 | 922 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_type_precision.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/quaternion.hpp>
#include <vector>
#if GLM_HAS_OPENMP
# include <omp.h>
#endif
static int test_scalar_size()
{
int Error(0);
Error += sizeof(glm::int8) != 1;
Error += sizeof(glm::int16) != 2;
Error += sizeof(glm::int32) != 4;
Error += sizeof(glm::int64) != 8;
Error += sizeof(glm::uint8) != 1;
Error += sizeof(glm::uint16) != 2;
Error += sizeof(glm::uint32) != 4;
Error += sizeof(glm::uint64) != 8;
Error += sizeof(glm::float32) != 4;
Error += sizeof(glm::float64) != 8;
Error += sizeof(glm::lowp_int8) != 1;
Error += sizeof(glm::lowp_int16) != 2;
Error += sizeof(glm::lowp_int32) != 4;
Error += sizeof(glm::lowp_int64) != 8;
Error += sizeof(glm::lowp_uint8) != 1;
Error += sizeof(glm::lowp_uint16) != 2;
Error += sizeof(glm::lowp_uint32) != 4;
Error += sizeof(glm::lowp_uint64) != 8;
Error += sizeof(glm::lowp_float32) != 4;
Error += sizeof(glm::lowp_float64) != 8;
Error += sizeof(glm::mediump_int8) != 1;
Error += sizeof(glm::mediump_int16) != 2;
Error += sizeof(glm::mediump_int32) != 4;
Error += sizeof(glm::mediump_int64) != 8;
Error += sizeof(glm::mediump_uint8) != 1;
Error += sizeof(glm::mediump_uint16) != 2;
Error += sizeof(glm::mediump_uint32) != 4;
Error += sizeof(glm::mediump_uint64) != 8;
Error += sizeof(glm::mediump_float32) != 4;
Error += sizeof(glm::mediump_float64) != 8;
Error += sizeof(glm::highp_int8) != 1;
Error += sizeof(glm::highp_int16) != 2;
Error += sizeof(glm::highp_int32) != 4;
Error += sizeof(glm::highp_int64) != 8;
Error += sizeof(glm::highp_uint8) != 1;
Error += sizeof(glm::highp_uint16) != 2;
Error += sizeof(glm::highp_uint32) != 4;
Error += sizeof(glm::highp_uint64) != 8;
Error += sizeof(glm::highp_float32) != 4;
Error += sizeof(glm::highp_float64) != 8;
return Error;
}
static int test_fvec_size()
{
int Error(0);
Error += sizeof(glm::f32vec2) != 8;
Error += sizeof(glm::f32vec3) != 12;
Error += sizeof(glm::f32vec4) != 16;
Error += sizeof(glm::f64vec2) != 16;
Error += sizeof(glm::f64vec3) != 24;
Error += sizeof(glm::f64vec4) != 32;
Error += sizeof(glm::lowp_f32vec2) != 8;
Error += sizeof(glm::lowp_f32vec3) != 12;
Error += sizeof(glm::lowp_f32vec4) != 16;
Error += sizeof(glm::lowp_f64vec2) != 16;
Error += sizeof(glm::lowp_f64vec3) != 24;
Error += sizeof(glm::lowp_f64vec4) != 32;
Error += sizeof(glm::mediump_f32vec2) != 8;
Error += sizeof(glm::mediump_f32vec3) != 12;
Error += sizeof(glm::mediump_f32vec4) != 16;
Error += sizeof(glm::mediump_f64vec2) != 16;
Error += sizeof(glm::mediump_f64vec3) != 24;
Error += sizeof(glm::mediump_f64vec4) != 32;
Error += sizeof(glm::highp_f32vec2) != 8;
Error += sizeof(glm::highp_f32vec3) != 12;
Error += sizeof(glm::highp_f32vec4) != 16;
Error += sizeof(glm::highp_f64vec2) != 16;
Error += sizeof(glm::highp_f64vec3) != 24;
Error += sizeof(glm::highp_f64vec4) != 32;
return Error;
}
static int test_fvec_precision()
{
int Error(0);
/*
{
glm::f32vec2 v1;
glm::lowp_f32vec2 v2((glm::f32vec2(v1)));
glm::mediump_f32vec2 v3((glm::f32vec2(v1)));
glm::highp_f32vec2 v4((glm::f32vec2(v1)));
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v4)) ? 0 : 1;
}
*/
{
glm::f32vec2 v1;
glm::lowp_f32vec2 v2(v1);
glm::mediump_f32vec2 v3(v1);
glm::highp_f32vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::f32vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec2(v4))) ? 0 : 1;
}
{
glm::f32vec3 v1;
glm::lowp_f32vec3 v2(v1);
glm::mediump_f32vec3 v3(v1);
glm::highp_f32vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::f32vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec3(v4))) ? 0 : 1;
}
{
glm::f32vec4 v1;
glm::lowp_f32vec4 v2(v1);
glm::mediump_f32vec4 v3(v1);
glm::highp_f32vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::f32vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_dvec_precision()
{
int Error(0);
{
glm::f64vec2 v1;
glm::lowp_f64vec2 v2(v1);
glm::mediump_f64vec2 v3(v1);
glm::highp_f64vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::f64vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec2(v4))) ? 0 : 1;
}
{
glm::f64vec3 v1;
glm::lowp_f64vec3 v2(v1);
glm::mediump_f64vec3 v3(v1);
glm::highp_f64vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::f64vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec3(v4))) ? 0 : 1;
}
{
glm::f64vec4 v1;
glm::lowp_f64vec4 v2(v1);
glm::mediump_f64vec4 v3(v1);
glm::highp_f64vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::f64vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_ivec_size()
{
int Error(0);
Error += sizeof(glm::i8vec2) != 2;
Error += sizeof(glm::i8vec3) != 3;
Error += sizeof(glm::i8vec4) != 4;
Error += sizeof(glm::i16vec2) != 4;
Error += sizeof(glm::i16vec3) != 6;
Error += sizeof(glm::i16vec4) != 8;
Error += sizeof(glm::i32vec2) != 8;
Error += sizeof(glm::i32vec3) != 12;
Error += sizeof(glm::i32vec4) != 16;
Error += sizeof(glm::i64vec2) != 16;
Error += sizeof(glm::i64vec3) != 24;
Error += sizeof(glm::i64vec4) != 32;
Error += sizeof(glm::lowp_i8vec2) != 2;
Error += sizeof(glm::lowp_i8vec3) != 3;
Error += sizeof(glm::lowp_i8vec4) != 4;
Error += sizeof(glm::lowp_i16vec2) != 4;
Error += sizeof(glm::lowp_i16vec3) != 6;
Error += sizeof(glm::lowp_i16vec4) != 8;
Error += sizeof(glm::lowp_i32vec2) != 8;
Error += sizeof(glm::lowp_i32vec3) != 12;
Error += sizeof(glm::lowp_i32vec4) != 16;
Error += sizeof(glm::lowp_i64vec2) != 16;
Error += sizeof(glm::lowp_i64vec3) != 24;
Error += sizeof(glm::lowp_i64vec4) != 32;
Error += sizeof(glm::mediump_i8vec2) != 2;
Error += sizeof(glm::mediump_i8vec3) != 3;
Error += sizeof(glm::mediump_i8vec4) != 4;
Error += sizeof(glm::mediump_i16vec2) != 4;
Error += sizeof(glm::mediump_i16vec3) != 6;
Error += sizeof(glm::mediump_i16vec4) != 8;
Error += sizeof(glm::mediump_i32vec2) != 8;
Error += sizeof(glm::mediump_i32vec3) != 12;
Error += sizeof(glm::mediump_i32vec4) != 16;
Error += sizeof(glm::mediump_i64vec2) != 16;
Error += sizeof(glm::mediump_i64vec3) != 24;
Error += sizeof(glm::mediump_i64vec4) != 32;
Error += sizeof(glm::highp_i8vec2) != 2;
Error += sizeof(glm::highp_i8vec3) != 3;
Error += sizeof(glm::highp_i8vec4) != 4;
Error += sizeof(glm::highp_i16vec2) != 4;
Error += sizeof(glm::highp_i16vec3) != 6;
Error += sizeof(glm::highp_i16vec4) != 8;
Error += sizeof(glm::highp_i32vec2) != 8;
Error += sizeof(glm::highp_i32vec3) != 12;
Error += sizeof(glm::highp_i32vec4) != 16;
Error += sizeof(glm::highp_i64vec2) != 16;
Error += sizeof(glm::highp_i64vec3) != 24;
Error += sizeof(glm::highp_i64vec4) != 32;
return Error;
}
static int test_ivec_precision()
{
int Error(0);
{
glm::i8vec2 v1;
glm::lowp_i8vec2 v2(v1);
glm::mediump_i8vec2 v3(v1);
glm::highp_i8vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i8vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec2(v4))) ? 0 : 1;
}
{
glm::i8vec3 v1;
glm::lowp_i8vec3 v2(v1);
glm::mediump_i8vec3 v3(v1);
glm::highp_i8vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i8vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec3(v4))) ? 0 : 1;
}
{
glm::i8vec4 v1;
glm::lowp_i8vec4 v2(v1);
glm::mediump_i8vec4 v3(v1);
glm::highp_i8vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i8vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec4(v4))) ? 0 : 1;
}
{
glm::i16vec2 v1;
glm::lowp_i16vec2 v2(v1);
glm::mediump_i16vec2 v3(v1);
glm::highp_i16vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i16vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec2(v4))) ? 0 : 1;
}
{
glm::i16vec3 v1;
glm::lowp_i16vec3 v2(v1);
glm::mediump_i16vec3 v3(v1);
glm::highp_i16vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i16vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec3(v4))) ? 0 : 1;
}
{
glm::i16vec4 v1;
glm::lowp_i16vec4 v2(v1);
glm::mediump_i16vec4 v3(v1);
glm::highp_i16vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i16vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec4(v4))) ? 0 : 1;
}
{
glm::i32vec2 v1;
glm::lowp_i32vec2 v2(v1);
glm::mediump_i32vec2 v3(v1);
glm::highp_i32vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i32vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec2(v4))) ? 0 : 1;
}
{
glm::i32vec3 v1;
glm::lowp_i32vec3 v2(v1);
glm::mediump_i32vec3 v3(v1);
glm::highp_i32vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i32vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec3(v4))) ? 0 : 1;
}
{
glm::i32vec4 v1;
glm::lowp_i32vec4 v2(v1);
glm::mediump_i32vec4 v3(v1);
glm::highp_i32vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i32vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec4(v4))) ? 0 : 1;
}
{
glm::i64vec2 v1;
glm::lowp_i64vec2 v2(v1);
glm::mediump_i64vec2 v3(v1);
glm::highp_i64vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i64vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec2(v4))) ? 0 : 1;
}
{
glm::i64vec3 v1;
glm::lowp_i64vec3 v2(v1);
glm::mediump_i64vec3 v3(v1);
glm::highp_i64vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i64vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec3(v4))) ? 0 : 1;
}
{
glm::i64vec4 v1;
glm::lowp_i64vec4 v2(v1);
glm::mediump_i64vec4 v3(v1);
glm::highp_i64vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i64vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_uvec_size()
{
int Error(0);
Error += sizeof(glm::u8vec2) != 2;
Error += sizeof(glm::u8vec3) != 3;
Error += sizeof(glm::u8vec4) != 4;
Error += sizeof(glm::u16vec2) != 4;
Error += sizeof(glm::u16vec3) != 6;
Error += sizeof(glm::u16vec4) != 8;
Error += sizeof(glm::u32vec2) != 8;
Error += sizeof(glm::u32vec3) != 12;
Error += sizeof(glm::u32vec4) != 16;
Error += sizeof(glm::u64vec2) != 16;
Error += sizeof(glm::u64vec3) != 24;
Error += sizeof(glm::u64vec4) != 32;
Error += sizeof(glm::lowp_u8vec2) != 2;
Error += sizeof(glm::lowp_u8vec3) != 3;
Error += sizeof(glm::lowp_u8vec4) != 4;
Error += sizeof(glm::lowp_u16vec2) != 4;
Error += sizeof(glm::lowp_u16vec3) != 6;
Error += sizeof(glm::lowp_u16vec4) != 8;
Error += sizeof(glm::lowp_u32vec2) != 8;
Error += sizeof(glm::lowp_u32vec3) != 12;
Error += sizeof(glm::lowp_u32vec4) != 16;
Error += sizeof(glm::lowp_u64vec2) != 16;
Error += sizeof(glm::lowp_u64vec3) != 24;
Error += sizeof(glm::lowp_u64vec4) != 32;
Error += sizeof(glm::mediump_u8vec2) != 2;
Error += sizeof(glm::mediump_u8vec3) != 3;
Error += sizeof(glm::mediump_u8vec4) != 4;
Error += sizeof(glm::mediump_u16vec2) != 4;
Error += sizeof(glm::mediump_u16vec3) != 6;
Error += sizeof(glm::mediump_u16vec4) != 8;
Error += sizeof(glm::mediump_u32vec2) != 8;
Error += sizeof(glm::mediump_u32vec3) != 12;
Error += sizeof(glm::mediump_u32vec4) != 16;
Error += sizeof(glm::mediump_u64vec2) != 16;
Error += sizeof(glm::mediump_u64vec3) != 24;
Error += sizeof(glm::mediump_u64vec4) != 32;
Error += sizeof(glm::highp_u8vec2) != 2;
Error += sizeof(glm::highp_u8vec3) != 3;
Error += sizeof(glm::highp_u8vec4) != 4;
Error += sizeof(glm::highp_u16vec2) != 4;
Error += sizeof(glm::highp_u16vec3) != 6;
Error += sizeof(glm::highp_u16vec4) != 8;
Error += sizeof(glm::highp_u32vec2) != 8;
Error += sizeof(glm::highp_u32vec3) != 12;
Error += sizeof(glm::highp_u32vec4) != 16;
Error += sizeof(glm::highp_u64vec2) != 16;
Error += sizeof(glm::highp_u64vec3) != 24;
Error += sizeof(glm::highp_u64vec4) != 32;
return Error;
}
static int test_uvec_precision()
{
int Error(0);
{
glm::u8vec2 v1;
glm::lowp_u8vec2 v2(v1);
glm::mediump_u8vec2 v3(v1);
glm::highp_u8vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u8vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec2(v4))) ? 0 : 1;
}
{
glm::u8vec3 v1;
glm::lowp_u8vec3 v2(v1);
glm::mediump_u8vec3 v3(v1);
glm::highp_u8vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u8vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec3(v4))) ? 0 : 1;
}
{
glm::u8vec4 v1;
glm::lowp_u8vec4 v2(v1);
glm::mediump_u8vec4 v3(v1);
glm::highp_u8vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u8vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec4(v4))) ? 0 : 1;
}
{
glm::u16vec2 v1;
glm::lowp_u16vec2 v2(v1);
glm::mediump_u16vec2 v3(v1);
glm::highp_u16vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u16vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec2(v4))) ? 0 : 1;
}
{
glm::u16vec3 v1;
glm::lowp_u16vec3 v2(v1);
glm::mediump_u16vec3 v3(v1);
glm::highp_u16vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u16vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec3(v4))) ? 0 : 1;
}
{
glm::u16vec4 v1;
glm::lowp_u16vec4 v2(v1);
glm::mediump_u16vec4 v3(v1);
glm::highp_u16vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u16vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec4(v4))) ? 0 : 1;
}
{
glm::u32vec2 v1;
glm::lowp_u32vec2 v2(v1);
glm::mediump_u32vec2 v3(v1);
glm::highp_u32vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u32vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec2(v4))) ? 0 : 1;
}
{
glm::u32vec3 v1;
glm::lowp_u32vec3 v2(v1);
glm::mediump_u32vec3 v3(v1);
glm::highp_u32vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u32vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec3(v4))) ? 0 : 1;
}
{
glm::u32vec4 v1;
glm::lowp_u32vec4 v2(v1);
glm::mediump_u32vec4 v3(v1);
glm::highp_u32vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u32vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec4(v4))) ? 0 : 1;
}
{
glm::u64vec2 v1;
glm::lowp_u64vec2 v2(v1);
glm::mediump_u64vec2 v3(v1);
glm::highp_u64vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u64vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec2(v4))) ? 0 : 1;
}
{
glm::u64vec3 v1;
glm::lowp_u64vec3 v2(v1);
glm::mediump_u64vec3 v3(v1);
glm::highp_u64vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u64vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec3(v4))) ? 0 : 1;
}
{
glm::u64vec4 v1;
glm::lowp_u64vec4 v2(v1);
glm::mediump_u64vec4 v3(v1);
glm::highp_u64vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u64vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_fmat_size()
{
int Error(0);
Error += sizeof(glm::mat2) != 16;
Error += sizeof(glm::mat3) != 36;
Error += sizeof(glm::mat4) != 64;
Error += sizeof(glm::mat2x2) != 16;
Error += sizeof(glm::mat2x3) != 24;
Error += sizeof(glm::mat2x4) != 32;
Error += sizeof(glm::mat3x2) != 24;
Error += sizeof(glm::mat3x3) != 36;
Error += sizeof(glm::mat3x4) != 48;
Error += sizeof(glm::mat4x2) != 32;
Error += sizeof(glm::mat4x3) != 48;
Error += sizeof(glm::mat4x4) != 64;
Error += sizeof(glm::fmat2) != 16;
Error += sizeof(glm::fmat3) != 36;
Error += sizeof(glm::fmat4) != 64;
Error += sizeof(glm::fmat2x2) != 16;
Error += sizeof(glm::fmat2x3) != 24;
Error += sizeof(glm::fmat2x4) != 32;
Error += sizeof(glm::fmat3x2) != 24;
Error += sizeof(glm::fmat3x3) != 36;
Error += sizeof(glm::fmat3x4) != 48;
Error += sizeof(glm::fmat4x2) != 32;
Error += sizeof(glm::fmat4x3) != 48;
Error += sizeof(glm::fmat4x4) != 64;
Error += sizeof(glm::f32mat2) != 16;
Error += sizeof(glm::f32mat3) != 36;
Error += sizeof(glm::f32mat4) != 64;
Error += sizeof(glm::f32mat2x2) != 16;
Error += sizeof(glm::f32mat2x3) != 24;
Error += sizeof(glm::f32mat2x4) != 32;
Error += sizeof(glm::f32mat3x2) != 24;
Error += sizeof(glm::f32mat3x3) != 36;
Error += sizeof(glm::f32mat3x4) != 48;
Error += sizeof(glm::f32mat4x2) != 32;
Error += sizeof(glm::f32mat4x3) != 48;
Error += sizeof(glm::f32mat4x4) != 64;
Error += sizeof(glm::lowp_mat2) != 16;
Error += sizeof(glm::lowp_mat3) != 36;
Error += sizeof(glm::lowp_mat4) != 64;
Error += sizeof(glm::lowp_mat2x2) != 16;
Error += sizeof(glm::lowp_mat2x3) != 24;
Error += sizeof(glm::lowp_mat2x4) != 32;
Error += sizeof(glm::lowp_mat3x2) != 24;
Error += sizeof(glm::lowp_mat3x3) != 36;
Error += sizeof(glm::lowp_mat3x4) != 48;
Error += sizeof(glm::lowp_mat4x2) != 32;
Error += sizeof(glm::lowp_mat4x3) != 48;
Error += sizeof(glm::lowp_mat4x4) != 64;
Error += sizeof(glm::lowp_fmat2) != 16;
Error += sizeof(glm::lowp_fmat3) != 36;
Error += sizeof(glm::lowp_fmat4) != 64;
Error += sizeof(glm::lowp_fmat2x2) != 16;
Error += sizeof(glm::lowp_fmat2x3) != 24;
Error += sizeof(glm::lowp_fmat2x4) != 32;
Error += sizeof(glm::lowp_fmat3x2) != 24;
Error += sizeof(glm::lowp_fmat3x3) != 36;
Error += sizeof(glm::lowp_fmat3x4) != 48;
Error += sizeof(glm::lowp_fmat4x2) != 32;
Error += sizeof(glm::lowp_fmat4x3) != 48;
Error += sizeof(glm::lowp_fmat4x4) != 64;
Error += sizeof(glm::lowp_f32mat2) != 16;
Error += sizeof(glm::lowp_f32mat3) != 36;
Error += sizeof(glm::lowp_f32mat4) != 64;
Error += sizeof(glm::lowp_f32mat2x2) != 16;
Error += sizeof(glm::lowp_f32mat2x3) != 24;
Error += sizeof(glm::lowp_f32mat2x4) != 32;
Error += sizeof(glm::lowp_f32mat3x2) != 24;
Error += sizeof(glm::lowp_f32mat3x3) != 36;
Error += sizeof(glm::lowp_f32mat3x4) != 48;
Error += sizeof(glm::lowp_f32mat4x2) != 32;
Error += sizeof(glm::lowp_f32mat4x3) != 48;
Error += sizeof(glm::lowp_f32mat4x4) != 64;
Error += sizeof(glm::mediump_mat2) != 16;
Error += sizeof(glm::mediump_mat3) != 36;
Error += sizeof(glm::mediump_mat4) != 64;
Error += sizeof(glm::mediump_mat2x2) != 16;
Error += sizeof(glm::mediump_mat2x3) != 24;
Error += sizeof(glm::mediump_mat2x4) != 32;
Error += sizeof(glm::mediump_mat3x2) != 24;
Error += sizeof(glm::mediump_mat3x3) != 36;
Error += sizeof(glm::mediump_mat3x4) != 48;
Error += sizeof(glm::mediump_mat4x2) != 32;
Error += sizeof(glm::mediump_mat4x3) != 48;
Error += sizeof(glm::mediump_mat4x4) != 64;
Error += sizeof(glm::mediump_fmat2) != 16;
Error += sizeof(glm::mediump_fmat3) != 36;
Error += sizeof(glm::mediump_fmat4) != 64;
Error += sizeof(glm::mediump_fmat2x2) != 16;
Error += sizeof(glm::mediump_fmat2x3) != 24;
Error += sizeof(glm::mediump_fmat2x4) != 32;
Error += sizeof(glm::mediump_fmat3x2) != 24;
Error += sizeof(glm::mediump_fmat3x3) != 36;
Error += sizeof(glm::mediump_fmat3x4) != 48;
Error += sizeof(glm::mediump_fmat4x2) != 32;
Error += sizeof(glm::mediump_fmat4x3) != 48;
Error += sizeof(glm::mediump_fmat4x4) != 64;
Error += sizeof(glm::mediump_f32mat2) != 16;
Error += sizeof(glm::mediump_f32mat3) != 36;
Error += sizeof(glm::mediump_f32mat4) != 64;
Error += sizeof(glm::mediump_f32mat2x2) != 16;
Error += sizeof(glm::mediump_f32mat2x3) != 24;
Error += sizeof(glm::mediump_f32mat2x4) != 32;
Error += sizeof(glm::mediump_f32mat3x2) != 24;
Error += sizeof(glm::mediump_f32mat3x3) != 36;
Error += sizeof(glm::mediump_f32mat3x4) != 48;
Error += sizeof(glm::mediump_f32mat4x2) != 32;
Error += sizeof(glm::mediump_f32mat4x3) != 48;
Error += sizeof(glm::mediump_f32mat4x4) != 64;
Error += sizeof(glm::highp_mat2) != 16;
Error += sizeof(glm::highp_mat3) != 36;
Error += sizeof(glm::highp_mat4) != 64;
Error += sizeof(glm::highp_mat2x2) != 16;
Error += sizeof(glm::highp_mat2x3) != 24;
Error += sizeof(glm::highp_mat2x4) != 32;
Error += sizeof(glm::highp_mat3x2) != 24;
Error += sizeof(glm::highp_mat3x3) != 36;
Error += sizeof(glm::highp_mat3x4) != 48;
Error += sizeof(glm::highp_mat4x2) != 32;
Error += sizeof(glm::highp_mat4x3) != 48;
Error += sizeof(glm::highp_mat4x4) != 64;
Error += sizeof(glm::highp_fmat2) != 16;
Error += sizeof(glm::highp_fmat3) != 36;
Error += sizeof(glm::highp_fmat4) != 64;
Error += sizeof(glm::highp_fmat2x2) != 16;
Error += sizeof(glm::highp_fmat2x3) != 24;
Error += sizeof(glm::highp_fmat2x4) != 32;
Error += sizeof(glm::highp_fmat3x2) != 24;
Error += sizeof(glm::highp_fmat3x3) != 36;
Error += sizeof(glm::highp_fmat3x4) != 48;
Error += sizeof(glm::highp_fmat4x2) != 32;
Error += sizeof(glm::highp_fmat4x3) != 48;
Error += sizeof(glm::highp_fmat4x4) != 64;
Error += sizeof(glm::highp_f32mat2) != 16;
Error += sizeof(glm::highp_f32mat3) != 36;
Error += sizeof(glm::highp_f32mat4) != 64;
Error += sizeof(glm::highp_f32mat2x2) != 16;
Error += sizeof(glm::highp_f32mat2x3) != 24;
Error += sizeof(glm::highp_f32mat2x4) != 32;
Error += sizeof(glm::highp_f32mat3x2) != 24;
Error += sizeof(glm::highp_f32mat3x3) != 36;
Error += sizeof(glm::highp_f32mat3x4) != 48;
Error += sizeof(glm::highp_f32mat4x2) != 32;
Error += sizeof(glm::highp_f32mat4x3) != 48;
Error += sizeof(glm::highp_f32mat4x4) != 64;
return Error;
}
static int test_dmat_size()
{
int Error(0);
Error += sizeof(glm::f64mat2) != 32;
Error += sizeof(glm::f64mat3) != 72;
Error += sizeof(glm::f64mat4) != 128;
Error += sizeof(glm::f64mat2x2) != 32;
Error += sizeof(glm::f64mat2x3) != 48;
Error += sizeof(glm::f64mat2x4) != 64;
Error += sizeof(glm::f64mat3x2) != 48;
Error += sizeof(glm::f64mat3x3) != 72;
Error += sizeof(glm::f64mat3x4) != 96;
Error += sizeof(glm::f64mat4x2) != 64;
Error += sizeof(glm::f64mat4x3) != 96;
Error += sizeof(glm::f64mat4x4) != 128;
Error += sizeof(glm::lowp_f64mat2) != 32;
Error += sizeof(glm::lowp_f64mat3) != 72;
Error += sizeof(glm::lowp_f64mat4) != 128;
Error += sizeof(glm::lowp_f64mat2x2) != 32;
Error += sizeof(glm::lowp_f64mat2x3) != 48;
Error += sizeof(glm::lowp_f64mat2x4) != 64;
Error += sizeof(glm::lowp_f64mat3x2) != 48;
Error += sizeof(glm::lowp_f64mat3x3) != 72;
Error += sizeof(glm::lowp_f64mat3x4) != 96;
Error += sizeof(glm::lowp_f64mat4x2) != 64;
Error += sizeof(glm::lowp_f64mat4x3) != 96;
Error += sizeof(glm::lowp_f64mat4x4) != 128;
Error += sizeof(glm::mediump_f64mat2) != 32;
Error += sizeof(glm::mediump_f64mat3) != 72;
Error += sizeof(glm::mediump_f64mat4) != 128;
Error += sizeof(glm::mediump_f64mat2x2) != 32;
Error += sizeof(glm::mediump_f64mat2x3) != 48;
Error += sizeof(glm::mediump_f64mat2x4) != 64;
Error += sizeof(glm::mediump_f64mat3x2) != 48;
Error += sizeof(glm::mediump_f64mat3x3) != 72;
Error += sizeof(glm::mediump_f64mat3x4) != 96;
Error += sizeof(glm::mediump_f64mat4x2) != 64;
Error += sizeof(glm::mediump_f64mat4x3) != 96;
Error += sizeof(glm::mediump_f64mat4x4) != 128;
Error += sizeof(glm::highp_f64mat2) != 32;
Error += sizeof(glm::highp_f64mat3) != 72;
Error += sizeof(glm::highp_f64mat4) != 128;
Error += sizeof(glm::highp_f64mat2x2) != 32;
Error += sizeof(glm::highp_f64mat2x3) != 48;
Error += sizeof(glm::highp_f64mat2x4) != 64;
Error += sizeof(glm::highp_f64mat3x2) != 48;
Error += sizeof(glm::highp_f64mat3x3) != 72;
Error += sizeof(glm::highp_f64mat3x4) != 96;
Error += sizeof(glm::highp_f64mat4x2) != 64;
Error += sizeof(glm::highp_f64mat4x3) != 96;
Error += sizeof(glm::highp_f64mat4x4) != 128;
return Error;
}
static int test_quat_size()
{
int Error = 0;
Error += sizeof(glm::f32quat) != 16;
Error += sizeof(glm::f64quat) != 32;
Error += sizeof(glm::lowp_f32quat) != 16;
Error += sizeof(glm::lowp_f64quat) != 32;
Error += sizeof(glm::mediump_f32quat) != 16;
Error += sizeof(glm::mediump_f64quat) != 32;
Error += sizeof(glm::highp_f32quat) != 16;
Error += sizeof(glm::highp_f64quat) != 32;
return Error;
}
static int test_quat_precision()
{
int Error(0);
{
glm::f32quat q1;
glm::lowp_f32quat qA(q1);
glm::mediump_f32quat qB(q1);
glm::highp_f32quat qC(q1);
glm::f32quat q2(qA);
glm::f32quat q3(qB);
glm::f32quat q4(qC);
Error += glm::all(glm::equal(q1, q2)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q3)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q4)) ? 0 : 1;
}
return Error;
}
static int test_fvec_conversion()
{
int Error(0);
{
glm::highp_vec4 a = glm::vec4(1, 2, 3, 4);
glm::mediump_vec4 b = glm::vec4(1, 2, 3, 4);
glm::lowp_vec4 c = b;
glm::mediump_vec4 d = c;
glm::lowp_ivec4 e = glm::ivec4(d);
glm::lowp_ivec3 f = glm::ivec3(e);
Error += glm::all(glm::equal(b, d)) ? 0 : 1;
}
return Error;
}
static int test_openmp()
{
std::vector<glm::u8vec3> VectorA(1000);
std::vector<glm::u8vec3> VectorB(1000);
std::vector<glm::u8vec3> VectorC(1000);
for (std::size_t i = 0; i < VectorA.size(); ++i)
{
VectorA[i] = glm::u8vec3(1, 1, 1);
VectorB[i] = glm::u8vec3(1, 1, 1);
}
#pragma omp parallel for default(none) shared(VectorA, VectorB, VectorC)
for (int i = 0; i < VectorC.size(); ++i)
{
VectorC[i] = VectorA[i] + VectorB[i];
}
return 0;
}
int main()
{
int Error(0);
Error += test_openmp();
Error += test_scalar_size();
Error += test_fvec_size();
Error += test_fvec_precision();
Error += test_fvec_conversion();
Error += test_dvec_precision();
Error += test_ivec_size();
Error += test_ivec_precision();
Error += test_uvec_size();
Error += test_uvec_precision();
Error += test_fmat_size();
Error += test_dmat_size();
Error += test_quat_size();
Error += test_quat_precision();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_round.cpp | .cpp | 7,295 | 309 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// 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/gtc/gtc_round.cpp
/// @date 2014-11-03 / 2014-11-03
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtc_round (dependence)
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/round.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/vec1.hpp>
#include <vector>
#include <ctime>
#include <cstdio>
namespace isPowerOfTwo
{
template <typename genType>
struct type
{
genType Value;
bool Return;
};
int test_int16()
{
type<glm::int16> const Data[] =
{
{0x0001, true},
{0x0002, true},
{0x0004, true},
{0x0080, true},
{0x0000, true},
{0x0003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int16>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_uint16()
{
type<glm::uint16> const Data[] =
{
{0x0001, true},
{0x0002, true},
{0x0004, true},
{0x0000, true},
{0x0000, true},
{0x0003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint16>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_int32()
{
type<int> const Data[] =
{
{0x00000001, true},
{0x00000002, true},
{0x00000004, true},
{0x0000000f, false},
{0x00000000, true},
{0x00000003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec1 Result = glm::isPowerOfTwo(glm::ivec1(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec1(Data[i].Return), Result)) ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec2 Result = glm::isPowerOfTwo(glm::ivec2(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec2(Data[i].Return), Result)) ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec3 Result = glm::isPowerOfTwo(glm::ivec3(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec3(Data[i].Return), Result)) ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec4 Result = glm::isPowerOfTwo(glm::ivec4(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec4(Data[i].Return), Result)) ? 0 : 1;
}
return Error;
}
int test_uint32()
{
type<glm::uint> const Data[] =
{
{0x00000001, true},
{0x00000002, true},
{0x00000004, true},
{0x80000000, true},
{0x00000000, true},
{0x00000003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_int16();
Error += test_uint16();
Error += test_int32();
Error += test_uint32();
return Error;
}
}//isPowerOfTwo
namespace ceilPowerOfTwo
{
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
{
genIUType tmp = Value;
genIUType result = genIUType(0);
while(tmp)
{
result = (tmp & (~tmp + 1)); // grab lowest bit
tmp &= ~result; // clear lowest bit
}
return result;
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ceilPowerOfTwo_loop(genType value)
{
return glm::isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
}
template <typename genType>
struct type
{
genType Value;
genType Return;
};
int test_int32()
{
type<glm::int32> const Data[] =
{
{0x0000ffff, 0x00010000},
{-3, -4},
{-8, -8},
{0x00000001, 0x00000001},
{0x00000002, 0x00000002},
{0x00000004, 0x00000004},
{0x00000007, 0x00000008},
{0x0000fff0, 0x00010000},
{0x0000f000, 0x00010000},
{0x08000000, 0x08000000},
{0x00000000, 0x00000000},
{0x00000003, 0x00000004}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int32>); i < n; ++i)
{
glm::int32 Result = glm::ceilPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_uint32()
{
type<glm::uint32> const Data[] =
{
{0x00000001, 0x00000001},
{0x00000002, 0x00000002},
{0x00000004, 0x00000004},
{0x00000007, 0x00000008},
{0x0000ffff, 0x00010000},
{0x0000fff0, 0x00010000},
{0x0000f000, 0x00010000},
{0x80000000, 0x80000000},
{0x00000000, 0x00000000},
{0x00000003, 0x00000004}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint32>); i < n; ++i)
{
glm::uint32 Result = glm::ceilPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int perf()
{
int Error(0);
std::vector<glm::uint> v;
v.resize(100000000);
std::clock_t Timestramp0 = std::clock();
for(glm::uint32 i = 0, n = static_cast<glm::uint>(v.size()); i < n; ++i)
v[i] = ceilPowerOfTwo_loop(i);
std::clock_t Timestramp1 = std::clock();
for(glm::uint32 i = 0, n = static_cast<glm::uint>(v.size()); i < n; ++i)
v[i] = glm::ceilPowerOfTwo(i);
std::clock_t Timestramp2 = std::clock();
std::printf("ceilPowerOfTwo_loop: %d clocks\n", static_cast<unsigned int>(Timestramp1 - Timestramp0));
std::printf("glm::ceilPowerOfTwo: %d clocks\n", static_cast<unsigned int>(Timestramp2 - Timestramp1));
return Error;
}
int test()
{
int Error(0);
Error += test_int32();
Error += test_uint32();
return Error;
}
}//namespace ceilPowerOfTwo
int main()
{
int Error(0);
Error += isPowerOfTwo::test();
Error += ceilPowerOfTwo::test();
# ifdef NDEBUG
Error += ceilPowerOfTwo::perf();
# endif//NDEBUG
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_quaternion.cpp | .cpp | 10,008 | 342 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_quaternion.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp>
#include <vector>
int test_quat_angle()
{
int Error = 0;
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(0, 1, 1)));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(1, 2, 3)));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
}
return Error;
}
int test_quat_angleAxis()
{
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::mix(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_mix()
{
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::mix(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_precision()
{
int Error = 0;
Error += sizeof(glm::lowp_quat) <= sizeof(glm::mediump_quat) ? 0 : 1;
Error += sizeof(glm::mediump_quat) <= sizeof(glm::highp_quat) ? 0 : 1;
return Error;
}
int test_quat_normalize()
{
int Error(0);
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 2));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(1, 2, 3));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
return Error;
}
int test_quat_euler()
{
int Error(0);
{
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
float Roll = glm::roll(q);
float Pitch = glm::pitch(q);
float Yaw = glm::yaw(q);
glm::vec3 Angles = glm::eulerAngles(q);
}
{
glm::dquat q(1.0f, 0.0f, 0.0f, 1.0f);
double Roll = glm::roll(q);
double Pitch = glm::pitch(q);
double Yaw = glm::yaw(q);
glm::dvec3 Angles = glm::eulerAngles(q);
}
return Error;
}
int test_quat_slerp()
{
int Error(0);
float const Epsilon = 0.0001f;//glm::epsilon<float>();
float sqrt2 = sqrt(2.0f)/2.0f;
glm::quat id;
glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f);
glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f);
// Testing a == 0
// Must be id
glm::quat id2 = glm::slerp(id, Y90rot, 0.0f);
Error += glm::all(glm::epsilonEqual(id, id2, Epsilon)) ? 0 : 1;
// Testing a == 1
// Must be 90° rotation on Y : 0 0.7 0 0.7
glm::quat Y90rot2 = glm::slerp(id, Y90rot, 1.0f);
Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot2, Epsilon)) ? 0 : 1;
// Testing standard, easy case
// Must be 45° rotation on Y : 0 0.38 0 0.92
glm::quat Y45rot1 = glm::slerp(id, Y90rot, 0.5f);
// Testing reverse case
// Must be 45° rotation on Y : 0 0.38 0 0.92
glm::quat Ym45rot2 = glm::slerp(Y90rot, id, 0.5f);
// Testing against full circle around the sphere instead of shortest path
// Must be 45° rotation on Y
// certainly not a 135° rotation
glm::quat Y45rot3 = glm::slerp(id , -Y90rot, 0.5f);
float Y45angle3 = glm::angle(Y45rot3);
Error += glm::epsilonEqual(Y45angle3, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Ym45rot2, Y45rot3, Epsilon)) ? 0 : 1;
// Same, but inverted
// Must also be 45° rotation on Y : 0 0.38 0 0.92
// -0 -0.38 -0 -0.92 is ok too
glm::quat Y45rot4 = glm::slerp(-Y90rot, id, 0.5f);
Error += glm::all(glm::epsilonEqual(Ym45rot2, -Y45rot4, Epsilon)) ? 0 : 1;
// Testing q1 = q2
// Must be 90° rotation on Y : 0 0.7 0 0.7
glm::quat Y90rot3 = glm::slerp(Y90rot, Y90rot, 0.5f);
Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot3, Epsilon)) ? 0 : 1;
// Testing 180° rotation
// Must be 90° rotation on almost any axis that is on the XZ plane
glm::quat XZ90rot = glm::slerp(id, -Y90rot, 0.5f);
float XZ90angle = glm::angle(XZ90rot); // Must be PI/4 = 0.78;
Error += glm::epsilonEqual(XZ90angle, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
// Testing almost equal quaternions (this test should pass through the linear interpolation)
// Must be 0 0.00X 0 0.99999
glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f);
// Testing quaternions with opposite sign
{
glm::quat a(-1, 0, 0, 0);
glm::quat result = glm::slerp(a, id, 0.5f);
Error += glm::epsilonEqual(glm::pow(glm::dot(id, result), 2.f), 1.f, 0.01f) ? 0 : 1;
}
return Error;
}
int test_quat_mul()
{
int Error(0);
glm::quat temp1 = glm::normalize(glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0)));
glm::quat temp2 = glm::normalize(glm::quat(0.5f, glm::vec3(1.0, 0.0, 0.0)));
glm::vec3 transformed0 = (temp1 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp1));
glm::vec3 temp4 = temp2 * transformed0 * glm::inverse(temp2);
glm::quat temp5 = glm::normalize(temp1 * temp2);
glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5);
{
glm::quat temp7;
temp7 *= temp5;
temp7 *= glm::inverse(temp5);
Error += temp7 != glm::quat();
}
return Error;
}
int test_quat_two_axis_ctr()
{
int Error(0);
glm::quat q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
glm::vec3 v1 = q1 * glm::vec3(1, 0, 0);
Error += glm::all(glm::epsilonEqual(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1;
glm::quat q2 = q1 * q1;
glm::vec3 v2 = q2 * glm::vec3(1, 0, 0);
Error += glm::all(glm::epsilonEqual(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
return Error;
}
int test_quat_type()
{
glm::quat A;
glm::dquat B;
return 0;
}
int test_quat_mul_vec()
{
int Error(0);
glm::quat q = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::vec3 v(1, 0, 0);
glm::vec3 u(q * v);
glm::vec3 w(u * q);
Error += glm::all(glm::epsilonEqual(v, w, 0.01f)) ? 0 : 1;
return Error;
}
int test_quat_ctr()
{
int Error(0);
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::quat>::value ? 0 : 1;
// Error += std::is_trivially_default_constructible<glm::dquat>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::quat>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::dquat>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::quat>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dquat>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::quat>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::dquat>::value ? 0 : 1;
# endif
# if GLM_HAS_INITIALIZER_LISTS
{
glm::quat A{0, 1, 2, 3};
std::vector<glm::quat> B{
{0, 1, 2, 3},
{0, 1, 2, 3}};
}
# endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error(0);
Error += test_quat_ctr();
Error += test_quat_mul_vec();
Error += test_quat_two_axis_ctr();
Error += test_quat_mul();
Error += test_quat_precision();
Error += test_quat_type();
Error += test_quat_angle();
Error += test_quat_angleAxis();
Error += test_quat_mix();
Error += test_quat_normalize();
Error += test_quat_euler();
Error += test_quat_slerp();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_bitfield.cpp | .cpp | 18,941 | 674 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_bitfield.cpp
/// @date 2014-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/bitfield.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/vector_relational.hpp>
#if GLM_ARCH != GLM_ARCH_PURE
# include <glm/detail/intrinsic_integer.hpp>
#endif
#include <ctime>
#include <cstdio>
#include <vector>
namespace mask
{
template <typename genType>
struct type
{
genType Value;
genType Return;
};
inline int mask_zero(int Bits)
{
return ~((~0) << Bits);
}
inline int mask_mix(int Bits)
{
return Bits >= sizeof(int) * 8 ? 0xffffffff : (static_cast<int>(1) << Bits) - static_cast<int>(1);
}
inline int mask_half(int Bits)
{
// We do the shift in two steps because 1 << 32 on an int is undefined.
int const Half = Bits >> 1;
int const Fill = ~0;
int const ShiftHaft = (Fill << Half);
int const Rest = Bits - Half;
int const Reversed = ShiftHaft << Rest;
return ~Reversed;
}
inline int mask_loop(int Bits)
{
int Mask = 0;
for(int Bit = 0; Bit < Bits; ++Bit)
Mask |= (static_cast<int>(1) << Bit);
return Mask;
}
int perf()
{
int const Count = 100000000;
std::clock_t Timestamp1 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_mix(i % 32);
}
std::clock_t Timestamp2 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_loop(i % 32);
}
std::clock_t Timestamp3 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = glm::mask(i % 32);
}
std::clock_t Timestamp4 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_zero(i % 32);
}
std::clock_t Timestamp5 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_half(i % 32);
}
std::clock_t Timestamp6 = std::clock();
std::clock_t TimeMix = Timestamp2 - Timestamp1;
std::clock_t TimeLoop = Timestamp3 - Timestamp2;
std::clock_t TimeDefault = Timestamp4 - Timestamp3;
std::clock_t TimeZero = Timestamp5 - Timestamp4;
std::clock_t TimeHalf = Timestamp6 - Timestamp5;
printf("mask[mix]: %d\n", static_cast<unsigned int>(TimeMix));
printf("mask[loop]: %d\n", static_cast<unsigned int>(TimeLoop));
printf("mask[default]: %d\n", static_cast<unsigned int>(TimeDefault));
printf("mask[zero]: %d\n", static_cast<unsigned int>(TimeZero));
printf("mask[half]: %d\n", static_cast<unsigned int>(TimeHalf));
return TimeDefault < TimeLoop ? 0 : 1;
}
int test_uint()
{
type<glm::uint> const Data[] =
{
{ 0, 0x00000000},
{ 1, 0x00000001},
{ 2, 0x00000003},
{ 3, 0x00000007},
{31, 0x7fffffff},
{32, 0xffffffff}
};
int Error(0);
/* mask_zero is sadly not a correct code
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_zero(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
*/
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_mix(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_half(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_loop(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = glm::mask(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_uvec4()
{
type<glm::ivec4> const Data[] =
{
{glm::ivec4( 0), glm::ivec4(0x00000000)},
{glm::ivec4( 1), glm::ivec4(0x00000001)},
{glm::ivec4( 2), glm::ivec4(0x00000003)},
{glm::ivec4( 3), glm::ivec4(0x00000007)},
{glm::ivec4(31), glm::ivec4(0x7fffffff)},
{glm::ivec4(32), glm::ivec4(0xffffffff)}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::ivec4>); i < n; ++i)
{
glm::ivec4 Result = glm::mask(Data[i].Value);
Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_uint();
Error += test_uvec4();
return Error;
}
}//namespace mask
namespace bitfieldInterleave3
{
template <typename PARAM, typename RET>
inline RET refBitfieldInterleave(PARAM x, PARAM y, PARAM z)
{
RET Result = 0;
for(RET i = 0; i < sizeof(PARAM) * 8; ++i)
{
Result |= ((RET(x) & (RET(1U) << i)) << ((i << 1) + 0));
Result |= ((RET(y) & (RET(1U) << i)) << ((i << 1) + 1));
Result |= ((RET(z) & (RET(1U) << i)) << ((i << 1) + 2));
}
return Result;
}
int test()
{
int Error(0);
glm::uint16 x_max = 1 << 11;
glm::uint16 y_max = 1 << 11;
glm::uint16 z_max = 1 << 11;
for(glm::uint16 z = 0; z < z_max; z += 27)
for(glm::uint16 y = 0; y < y_max; y += 27)
for(glm::uint16 x = 0; x < x_max; x += 27)
{
glm::uint64 ResultA = refBitfieldInterleave<glm::uint16, glm::uint64>(x, y, z);
glm::uint64 ResultB = glm::bitfieldInterleave(x, y, z);
Error += ResultA == ResultB ? 0 : 1;
}
return Error;
}
}
namespace bitfieldInterleave4
{
template <typename PARAM, typename RET>
inline RET loopBitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w)
{
RET const v[4] = {x, y, z, w};
RET Result = 0;
for(RET i = 0; i < sizeof(PARAM) * 8; i++)
{
Result |= ((((v[0] >> i) & 1U)) << ((i << 2) + 0));
Result |= ((((v[1] >> i) & 1U)) << ((i << 2) + 1));
Result |= ((((v[2] >> i) & 1U)) << ((i << 2) + 2));
Result |= ((((v[3] >> i) & 1U)) << ((i << 2) + 3));
}
return Result;
}
int test()
{
int Error(0);
glm::uint16 x_max = 1 << 11;
glm::uint16 y_max = 1 << 11;
glm::uint16 z_max = 1 << 11;
glm::uint16 w_max = 1 << 11;
for(glm::uint16 w = 0; w < w_max; w += 27)
for(glm::uint16 z = 0; z < z_max; z += 27)
for(glm::uint16 y = 0; y < y_max; y += 27)
for(glm::uint16 x = 0; x < x_max; x += 27)
{
glm::uint64 ResultA = loopBitfieldInterleave<glm::uint16, glm::uint64>(x, y, z, w);
glm::uint64 ResultB = glm::bitfieldInterleave(x, y, z, w);
Error += ResultA == ResultB ? 0 : 1;
}
return Error;
}
}
namespace bitfieldInterleave
{
inline glm::uint64 fastBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
glm::uint64 REG1;
glm::uint64 REG2;
REG1 = x;
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
REG2 = y;
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
return REG1 | (REG2 << 1);
}
inline glm::uint64 interleaveBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
glm::uint64 REG1;
glm::uint64 REG2;
REG1 = x;
REG2 = y;
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
return REG1 | (REG2 << 1);
}
inline glm::uint64 loopBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
static glm::uint64 const Mask[5] =
{
0x5555555555555555,
0x3333333333333333,
0x0F0F0F0F0F0F0F0F,
0x00FF00FF00FF00FF,
0x0000FFFF0000FFFF
};
glm::uint64 REG1 = x;
glm::uint64 REG2 = y;
for(int i = 4; i >= 0; --i)
{
REG1 = ((REG1 << (1 << i)) | REG1) & Mask[i];
REG2 = ((REG2 << (1 << i)) | REG2) & Mask[i];
}
return REG1 | (REG2 << 1);
}
#if(GLM_ARCH != GLM_ARCH_PURE)
inline glm::uint64 sseBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
GLM_ALIGN(16) glm::uint32 const Array[4] = {x, 0, y, 0};
__m128i const Mask4 = _mm_set1_epi32(0x0000FFFF);
__m128i const Mask3 = _mm_set1_epi32(0x00FF00FF);
__m128i const Mask2 = _mm_set1_epi32(0x0F0F0F0F);
__m128i const Mask1 = _mm_set1_epi32(0x33333333);
__m128i const Mask0 = _mm_set1_epi32(0x55555555);
__m128i Reg1;
__m128i Reg2;
// REG1 = x;
// REG2 = y;
Reg1 = _mm_load_si128((__m128i*)Array);
//REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
//REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
Reg2 = _mm_slli_si128(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask4);
//REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
//REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
Reg2 = _mm_slli_si128(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask3);
//REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
//REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
Reg2 = _mm_slli_epi32(Reg1, 4);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask2);
//REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
//REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
Reg2 = _mm_slli_epi32(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask1);
//REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
//REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask0);
//return REG1 | (REG2 << 1);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg2 = _mm_srli_si128(Reg2, 8);
Reg1 = _mm_or_si128(Reg1, Reg2);
GLM_ALIGN(16) glm::uint64 Result[2];
_mm_store_si128((__m128i*)Result, Reg1);
return Result[0];
}
inline glm::uint64 sseUnalignedBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
glm::uint32 const Array[4] = {x, 0, y, 0};
__m128i const Mask4 = _mm_set1_epi32(0x0000FFFF);
__m128i const Mask3 = _mm_set1_epi32(0x00FF00FF);
__m128i const Mask2 = _mm_set1_epi32(0x0F0F0F0F);
__m128i const Mask1 = _mm_set1_epi32(0x33333333);
__m128i const Mask0 = _mm_set1_epi32(0x55555555);
__m128i Reg1;
__m128i Reg2;
// REG1 = x;
// REG2 = y;
Reg1 = _mm_loadu_si128((__m128i*)Array);
//REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
//REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
Reg2 = _mm_slli_si128(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask4);
//REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
//REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
Reg2 = _mm_slli_si128(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask3);
//REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
//REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
Reg2 = _mm_slli_epi32(Reg1, 4);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask2);
//REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
//REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
Reg2 = _mm_slli_epi32(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask1);
//REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
//REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask0);
//return REG1 | (REG2 << 1);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg2 = _mm_srli_si128(Reg2, 8);
Reg1 = _mm_or_si128(Reg1, Reg2);
glm::uint64 Result[2];
_mm_storeu_si128((__m128i*)Result, Reg1);
return Result[0];
}
#endif//(GLM_ARCH != GLM_ARCH_PURE)
int test()
{
{
for(glm::uint32 y = 0; y < (1 << 10); ++y)
for(glm::uint32 x = 0; x < (1 << 10); ++x)
{
glm::uint64 A = glm::bitfieldInterleave(x, y);
glm::uint64 B = fastBitfieldInterleave(x, y);
glm::uint64 C = loopBitfieldInterleave(x, y);
glm::uint64 D = interleaveBitfieldInterleave(x, y);
assert(A == B);
assert(A == C);
assert(A == D);
# if(GLM_ARCH != GLM_ARCH_PURE)
glm::uint64 E = sseBitfieldInterleave(x, y);
glm::uint64 F = sseUnalignedBitfieldInterleave(x, y);
assert(A == E);
assert(A == F);
__m128i G = glm::detail::_mm_bit_interleave_si128(_mm_set_epi32(0, y, 0, x));
glm::uint64 Result[2];
_mm_storeu_si128((__m128i*)Result, G);
assert(A == Result[0]);
# endif//(GLM_ARCH != GLM_ARCH_PURE)
}
}
{
for(glm::uint8 y = 0; y < 127; ++y)
for(glm::uint8 x = 0; x < 127; ++x)
{
glm::uint64 A(glm::bitfieldInterleave(glm::uint8(x), glm::uint8(y)));
glm::uint64 B(glm::bitfieldInterleave(glm::uint16(x), glm::uint16(y)));
glm::uint64 C(glm::bitfieldInterleave(glm::uint32(x), glm::uint32(y)));
glm::int64 D(glm::bitfieldInterleave(glm::int8(x), glm::int8(y)));
glm::int64 E(glm::bitfieldInterleave(glm::int16(x), glm::int16(y)));
glm::int64 F(glm::bitfieldInterleave(glm::int32(x), glm::int32(y)));
assert(D == E);
assert(D == F);
}
}
return 0;
}
int perf()
{
glm::uint32 x_max = 1 << 11;
glm::uint32 y_max = 1 << 10;
// ALU
std::vector<glm::uint64> Data(x_max * y_max);
std::vector<glm::u32vec2> Param(x_max * y_max);
for(glm::uint32 i = 0; i < Param.size(); ++i)
Param[i] = glm::u32vec2(i % x_max, i / y_max);
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::bitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("glm::bitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = fastBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("fastBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = loopBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("loopBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = interleaveBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("interleaveBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# if(GLM_ARCH != GLM_ARCH_PURE)
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = sseBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("sseBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = sseUnalignedBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("sseUnalignedBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# endif//(GLM_ARCH != GLM_ARCH_PURE)
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::bitfieldInterleave(Param[i].x, Param[i].y, Param[i].x);
std::clock_t Time = std::clock() - LastTime;
std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# if(GLM_ARCH != GLM_ARCH_PURE)
{
// SIMD
std::vector<__m128i> SimdData(x_max * y_max);
std::vector<__m128i> SimdParam(x_max * y_max);
for(int i = 0; i < SimdParam.size(); ++i)
SimdParam[i] = _mm_set_epi32(i % x_max, 0, i / y_max, 0);
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < SimdData.size(); ++i)
SimdData[i] = glm::detail::_mm_bit_interleave_si128(SimdParam[i]);
std::clock_t Time = std::clock() - LastTime;
std::printf("_mm_bit_interleave_si128 Time %d clocks\n", static_cast<unsigned int>(Time));
}
# endif//(GLM_ARCH != GLM_ARCH_PURE)
return 0;
}
}//namespace bitfieldInterleave
int main()
{
int Error(0);
Error += ::mask::test();
Error += ::bitfieldInterleave3::test();
Error += ::bitfieldInterleave4::test();
Error += ::bitfieldInterleave::test();
//Error += ::bitRevert::test();
# ifdef NDEBUG
Error += ::mask::perf();
Error += ::bitfieldInterleave::perf();
# endif//NDEBUG
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_matrix_transform.cpp | .cpp | 2,554 | 86 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_matrix_transform.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/constants.hpp>
int test_perspective()
{
int Error = 0;
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
return Error;
}
int test_pick()
{
int Error = 0;
glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240));
return Error;
}
int test_tweakedInfinitePerspective()
{
int Error = 0;
glm::mat4 ProjectionA = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f);
glm::mat4 ProjectionB = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f, 0.001f);
return Error;
}
int test_translate()
{
int Error = 0;
glm::lowp_vec3 v(1.0);
glm::lowp_mat4 m(0);
glm::lowp_mat4 t = glm::translate(m, v);
return Error;
}
int main()
{
int Error = 0;
Error += test_translate();
Error += test_tweakedInfinitePerspective();
Error += test_pick();
Error += test_perspective();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_matrix_integer.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/gtc/gtc_matrix_integer.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_integer.hpp>
int main()
{
int Error = 0;
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_epsilon.cpp | .cpp | 3,440 | 109 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_epsilon.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/vector_relational.hpp>
int test_defined()
{
glm::epsilonEqual(glm::vec2(), glm::vec2(), glm::vec2());
glm::epsilonEqual(glm::vec3(), glm::vec3(), glm::vec3());
glm::epsilonEqual(glm::vec4(), glm::vec4(), glm::vec4());
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), glm::vec2());
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), glm::vec3());
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), glm::vec4());
glm::epsilonEqual(glm::vec2(), glm::vec2(), 0.0f);
glm::epsilonEqual(glm::vec3(), glm::vec3(), 0.0f);
glm::epsilonEqual(glm::vec4(), glm::vec4(), 0.0f);
glm::epsilonEqual(glm::quat(), glm::quat(), 0.0f);
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), 0.0f);
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), 0.0f);
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), 0.0f);
glm::epsilonNotEqual(glm::quat(), glm::quat(), 0.0f);
return 0;
}
template <typename T>
int test_equal()
{
int Error(0);
{
T A = glm::epsilon<T>();
T B = glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A(0);
T B = static_cast<T>(0) + glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A(0);
T B = static_cast<T>(0) - glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A = static_cast<T>(0) + glm::epsilon<T>();
T B = static_cast<T>(0);
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A = static_cast<T>(0) - glm::epsilon<T>();
T B = static_cast<T>(0);
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
return Error;
}
int main()
{
int Error(0);
Error += test_defined();
Error += test_equal<float>();
Error += test_equal<double>();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/test/gtc/gtc_matrix_access.cpp | .cpp | 10,613 | 413 | ///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_matrix_access.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_access.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
int test_mat2x2_row_set()
{
int Error = 0;
glm::mat2x2 m(1);
m = glm::row(m, 0, glm::vec2( 0, 1));
m = glm::row(m, 1, glm::vec2( 4, 5));
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
return Error;
}
int test_mat2x2_col_set()
{
int Error = 0;
glm::mat2x2 m(1);
m = glm::column(m, 0, glm::vec2( 0, 1));
m = glm::column(m, 1, glm::vec2( 4, 5));
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
return Error;
}
int test_mat2x3_row_set()
{
int Error = 0;
glm::mat2x3 m(1);
m = glm::row(m, 0, glm::vec2( 0, 1));
m = glm::row(m, 1, glm::vec2( 4, 5));
m = glm::row(m, 2, glm::vec2( 8, 9));
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
return Error;
}
int test_mat2x3_col_set()
{
int Error = 0;
glm::mat2x3 m(1);
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
return Error;
}
int test_mat2x4_row_set()
{
int Error = 0;
glm::mat2x4 m(1);
m = glm::row(m, 0, glm::vec2( 0, 1));
m = glm::row(m, 1, glm::vec2( 4, 5));
m = glm::row(m, 2, glm::vec2( 8, 9));
m = glm::row(m, 3, glm::vec2(12, 13));
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
Error += glm::row(m, 3) == glm::vec2(12, 13) ? 0 : 1;
return Error;
}
int test_mat2x4_col_set()
{
int Error = 0;
glm::mat2x4 m(1);
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
return Error;
}
int test_mat3x2_row_set()
{
int Error = 0;
glm::mat3x2 m(1);
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
return Error;
}
int test_mat3x2_col_set()
{
int Error = 0;
glm::mat3x2 m(1);
m = glm::column(m, 0, glm::vec2( 0, 1));
m = glm::column(m, 1, glm::vec2( 4, 5));
m = glm::column(m, 2, glm::vec2( 8, 9));
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
return Error;
}
int test_mat3x3_row_set()
{
int Error = 0;
glm::mat3x3 m(1);
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
m = glm::row(m, 2, glm::vec3( 8, 9, 10));
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
return Error;
}
int test_mat3x3_col_set()
{
int Error = 0;
glm::mat3x3 m(1);
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
m = glm::column(m, 2, glm::vec3( 8, 9, 10));
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
return Error;
}
int test_mat3x4_row_set()
{
int Error = 0;
glm::mat3x4 m(1);
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
m = glm::row(m, 2, glm::vec3( 8, 9, 10));
m = glm::row(m, 3, glm::vec3(12, 13, 14));
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
Error += glm::row(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1;
return Error;
}
int test_mat3x4_col_set()
{
int Error = 0;
glm::mat3x4 m(1);
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11));
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
return Error;
}
int test_mat4x2_row_set()
{
int Error = 0;
glm::mat4x2 m(1);
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
return Error;
}
int test_mat4x2_col_set()
{
int Error = 0;
glm::mat4x2 m(1);
m = glm::column(m, 0, glm::vec2( 0, 1));
m = glm::column(m, 1, glm::vec2( 4, 5));
m = glm::column(m, 2, glm::vec2( 8, 9));
m = glm::column(m, 3, glm::vec2(12, 13));
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
Error += glm::column(m, 3) == glm::vec2(12, 13) ? 0 : 1;
return Error;
}
int test_mat4x3_row_set()
{
int Error = 0;
glm::mat4x3 m(1);
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11));
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
return Error;
}
int test_mat4x3_col_set()
{
int Error = 0;
glm::mat4x3 m(1);
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
m = glm::column(m, 2, glm::vec3( 8, 9, 10));
m = glm::column(m, 3, glm::vec3(12, 13, 14));
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
Error += glm::column(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1;
return Error;
}
int test_mat4x4_row_set()
{
int Error = 0;
glm::mat4 m(1);
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11));
m = glm::row(m, 3, glm::vec4(12, 13, 14, 15));
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
Error += glm::row(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1;
return Error;
}
int test_mat4x4_col_set()
{
int Error = 0;
glm::mat4 m(1);
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11));
m = glm::column(m, 3, glm::vec4(12, 13, 14, 15));
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
Error += glm::column(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1;
return Error;
}
int test_mat4x4_row_get()
{
int Error = 0;
glm::mat4 m(1);
glm::vec4 A = glm::row(m, 0);
Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1;
glm::vec4 B = glm::row(m, 1);
Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1;
glm::vec4 C = glm::row(m, 2);
Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1;
glm::vec4 D = glm::row(m, 3);
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
return Error;
}
int test_mat4x4_col_get()
{
int Error = 0;
glm::mat4 m(1);
glm::vec4 A = glm::column(m, 0);
Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1;
glm::vec4 B = glm::column(m, 1);
Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1;
glm::vec4 C = glm::column(m, 2);
Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1;
glm::vec4 D = glm::column(m, 3);
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_mat2x2_row_set();
Error += test_mat2x2_col_set();
Error += test_mat2x3_row_set();
Error += test_mat2x3_col_set();
Error += test_mat2x4_row_set();
Error += test_mat2x4_col_set();
Error += test_mat3x2_row_set();
Error += test_mat3x2_col_set();
Error += test_mat3x3_row_set();
Error += test_mat3x3_col_set();
Error += test_mat3x4_row_set();
Error += test_mat3x4_col_set();
Error += test_mat4x2_row_set();
Error += test_mat4x2_col_set();
Error += test_mat4x3_row_set();
Error += test_mat4x3_col_set();
Error += test_mat4x4_row_set();
Error += test_mat4x4_col_set();
Error += test_mat4x4_row_get();
Error += test_mat4x4_col_get();
return Error;
}
| C++ |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat2x4.hpp | .hpp | 3,060 | 61 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat2x4.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat2x4.hpp"
namespace glm
{
/// 2 columns of 4 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x4<float, lowp> lowp_mat2x4;
/// 2 columns of 4 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x4<float, mediump> mediump_mat2x4;
/// 2 columns of 4 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x4<float, highp> highp_mat2x4;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/matrix.hpp | .hpp | 1,644 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/matrix.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_matrix.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/geometric.hpp | .hpp | 1,650 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/geometric.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_geometric.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/vec3.hpp | .hpp | 1,640 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/vec3.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_vec3.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/common.hpp | .hpp | 1,644 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/common.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_common.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat3x4.hpp | .hpp | 3,060 | 61 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat3x4.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat3x4.hpp"
namespace glm
{
/// 3 columns of 4 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x4<float, lowp> lowp_mat3x4;
/// 3 columns of 4 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x4<float, mediump> mediump_mat3x4;
/// 3 columns of 4 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x4<float, highp> highp_mat3x4;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/fwd.hpp | .hpp | 81,805 | 2,602 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/fwd.hpp
/// @date 2013-03-30 / 2013-03-31
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_int.hpp"
#include "detail/type_float.hpp"
#include "detail/type_vec.hpp"
#include "detail/type_mat.hpp"
//////////////////////
// GLM_GTC_quaternion
namespace glm
{
template <typename T, precision P> struct tquat;
/// Quaternion of low single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef tquat<float, lowp> lowp_quat;
/// Quaternion of medium single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef tquat<float, mediump> mediump_quat;
/// Quaternion of high single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef tquat<float, highp> highp_quat;
#if(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
typedef highp_quat quat;
#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
typedef mediump_quat quat;
#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
typedef lowp_quat quat;
#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
/// Quaternion of default single-precision floating-point numbers.
typedef highp_quat quat;
#endif
/// Quaternion of low single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef lowp_quat lowp_fquat;
/// Quaternion of medium single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef mediump_quat mediump_fquat;
/// Quaternion of high single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef highp_quat highp_fquat;
/// Quaternion of default single-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef quat fquat;
/// Quaternion of low double-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef tquat<double, lowp> lowp_dquat;
/// Quaternion of medium double-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef tquat<double, mediump> mediump_dquat;
/// Quaternion of high double-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef tquat<double, highp> highp_dquat;
#if(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
typedef highp_dquat dquat;
#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
typedef mediump_dquat dquat;
#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
typedef lowp_dquat dquat;
#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
/// Quaternion of default double-precision floating-point numbers.
///
/// @see gtc_quaternion
typedef highp_dquat dquat;
#endif
}//namespace glm
//////////////////////
// GLM_GTC_precision
namespace glm
{
/// @addtogroup gtc_type_precision
/// @{
/// Low precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_int8;
/// Low precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 lowp_int16;
/// Low precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 lowp_int32;
/// Low precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 lowp_int64;
/// Low precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_int8_t;
/// Low precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 lowp_int16_t;
/// Low precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 lowp_int32_t;
/// Low precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 lowp_int64_t;
/// Low precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_i8;
/// Low precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 lowp_i16;
/// Low precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 lowp_i32;
/// Low precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 lowp_i64;
/// Medium precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 mediump_int8;
/// Medium precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 mediump_int16;
/// Medium precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 mediump_int32;
/// Medium precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 mediump_int64;
/// Medium precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 mediump_int8_t;
/// Medium precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 mediump_int16_t;
/// Medium precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 mediump_int32_t;
/// Medium precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 mediump_int64_t;
/// Medium precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 mediump_i8;
/// Medium precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 mediump_i16;
/// Medium precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 mediump_i32;
/// Medium precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 mediump_i64;
/// High precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 highp_int8;
/// High precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 highp_int16;
/// High precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 highp_int32;
/// High precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 highp_int64;
/// High precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 highp_int8_t;
/// High precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 highp_int16_t;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 highp_int32_t;
/// High precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 highp_int64_t;
/// High precision 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 highp_i8;
/// High precision 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 highp_i16;
/// High precision 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 highp_i32;
/// High precision 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 highp_i64;
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 int8;
/// 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 int16;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 int32;
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 int64;
#if GLM_HAS_EXTENDED_INTEGER_TYPE
using std::int8_t;
using std::int16_t;
using std::int32_t;
using std::int64_t;
#else
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 int8_t;
/// 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 int16_t;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 int32_t;
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 int64_t;
#endif
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 i8;
/// 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 i16;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 i32;
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 i64;
/// Low precision 8 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i8, lowp> lowp_i8vec1;
/// Low precision 8 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i8, lowp> lowp_i8vec2;
/// Low precision 8 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i8, lowp> lowp_i8vec3;
/// Low precision 8 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i8, lowp> lowp_i8vec4;
/// Medium precision 8 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i8, mediump> mediump_i8vec1;
/// Medium precision 8 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i8, mediump> mediump_i8vec2;
/// Medium precision 8 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i8, mediump> mediump_i8vec3;
/// Medium precision 8 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i8, mediump> mediump_i8vec4;
/// High precision 8 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i8, highp> highp_i8vec1;
/// High precision 8 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i8, highp> highp_i8vec2;
/// High precision 8 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i8, highp> highp_i8vec3;
/// High precision 8 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i8, highp> highp_i8vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_i8vec1 i8vec1;
typedef lowp_i8vec2 i8vec2;
typedef lowp_i8vec3 i8vec3;
typedef lowp_i8vec4 i8vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_i8vec1 i8vec1;
typedef mediump_i8vec2 i8vec2;
typedef mediump_i8vec3 i8vec3;
typedef mediump_i8vec4 i8vec4;
#else
/// Default precision 8 bit signed integer scalar type.
/// @see gtc_type_precision
typedef highp_i8vec1 i8vec1;
/// Default precision 8 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_i8vec2 i8vec2;
/// Default precision 8 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_i8vec3 i8vec3;
/// Default precision 8 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_i8vec4 i8vec4;
#endif
/// Low precision 16 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i16, lowp> lowp_i16vec1;
/// Low precision 16 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i16, lowp> lowp_i16vec2;
/// Low precision 16 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i16, lowp> lowp_i16vec3;
/// Low precision 16 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i16, lowp> lowp_i16vec4;
/// Medium precision 16 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i16, mediump> mediump_i16vec1;
/// Medium precision 16 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i16, mediump> mediump_i16vec2;
/// Medium precision 16 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i16, mediump> mediump_i16vec3;
/// Medium precision 16 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i16, mediump> mediump_i16vec4;
/// High precision 16 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i16, highp> highp_i16vec1;
/// High precision 16 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i16, highp> highp_i16vec2;
/// High precision 16 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i16, highp> highp_i16vec3;
/// High precision 16 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i16, highp> highp_i16vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_i16vec1 i16vec1;
typedef lowp_i16vec2 i16vec2;
typedef lowp_i16vec3 i16vec3;
typedef lowp_i16vec4 i16vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_i16vec1 i16vec1;
typedef mediump_i16vec2 i16vec2;
typedef mediump_i16vec3 i16vec3;
typedef mediump_i16vec4 i16vec4;
#else
/// Default precision 16 bit signed integer scalar type.
/// @see gtc_type_precision
typedef highp_i16vec1 i16vec1;
/// Default precision 16 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_i16vec2 i16vec2;
/// Default precision 16 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_i16vec3 i16vec3;
/// Default precision 16 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_i16vec4 i16vec4;
#endif
/// Low precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i32, lowp> lowp_i32vec1;
/// Low precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i32, lowp> lowp_i32vec2;
/// Low precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i32, lowp> lowp_i32vec3;
/// Low precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i32, lowp> lowp_i32vec4;
/// Medium precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i32, mediump> mediump_i32vec1;
/// Medium precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i32, mediump> mediump_i32vec2;
/// Medium precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i32, mediump> mediump_i32vec3;
/// Medium precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i32, mediump> mediump_i32vec4;
/// High precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i32, highp> highp_i32vec1;
/// High precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i32, highp> highp_i32vec2;
/// High precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i32, highp> highp_i32vec3;
/// High precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i32, highp> highp_i32vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_i32vec1 i32vec1;
typedef lowp_i32vec2 i32vec2;
typedef lowp_i32vec3 i32vec3;
typedef lowp_i32vec4 i32vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_i32vec1 i32vec1;
typedef mediump_i32vec2 i32vec2;
typedef mediump_i32vec3 i32vec3;
typedef mediump_i32vec4 i32vec4;
#else
/// Default precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef highp_i32vec1 i32vec1;
/// Default precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_i32vec2 i32vec2;
/// Default precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_i32vec3 i32vec3;
/// Default precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_i32vec4 i32vec4;
#endif
/// Low precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i32, lowp> lowp_i32vec1;
/// Low precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i32, lowp> lowp_i32vec2;
/// Low precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i32, lowp> lowp_i32vec3;
/// Low precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i32, lowp> lowp_i32vec4;
/// Medium precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i32, mediump> mediump_i32vec1;
/// Medium precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i32, mediump> mediump_i32vec2;
/// Medium precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i32, mediump> mediump_i32vec3;
/// Medium precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i32, mediump> mediump_i32vec4;
/// High precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i32, highp> highp_i32vec1;
/// High precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i32, highp> highp_i32vec2;
/// High precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i32, highp> highp_i32vec3;
/// High precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i32, highp> highp_i32vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_i32vec1 i32vec1;
typedef lowp_i32vec2 i32vec2;
typedef lowp_i32vec3 i32vec3;
typedef lowp_i32vec4 i32vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_i32vec1 i32vec1;
typedef mediump_i32vec2 i32vec2;
typedef mediump_i32vec3 i32vec3;
typedef mediump_i32vec4 i32vec4;
#else
/// Default precision 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef highp_i32vec1 i32vec1;
/// Default precision 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_i32vec2 i32vec2;
/// Default precision 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_i32vec3 i32vec3;
/// Default precision 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_i32vec4 i32vec4;
#endif
/// Low precision 64 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i64, lowp> lowp_i64vec1;
/// Low precision 64 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i64, lowp> lowp_i64vec2;
/// Low precision 64 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i64, lowp> lowp_i64vec3;
/// Low precision 64 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i64, lowp> lowp_i64vec4;
/// Medium precision 64 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i64, mediump> mediump_i64vec1;
/// Medium precision 64 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i64, mediump> mediump_i64vec2;
/// Medium precision 64 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i64, mediump> mediump_i64vec3;
/// Medium precision 64 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i64, mediump> mediump_i64vec4;
/// High precision 64 bit signed integer scalar type.
/// @see gtc_type_precision
typedef tvec1<i64, highp> highp_i64vec1;
/// High precision 64 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<i64, highp> highp_i64vec2;
/// High precision 64 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<i64, highp> highp_i64vec3;
/// High precision 64 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<i64, highp> highp_i64vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_i64vec1 i64vec1;
typedef lowp_i64vec2 i64vec2;
typedef lowp_i64vec3 i64vec3;
typedef lowp_i64vec4 i64vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_i64vec1 i64vec1;
typedef mediump_i64vec2 i64vec2;
typedef mediump_i64vec3 i64vec3;
typedef mediump_i64vec4 i64vec4;
#else
/// Default precision 64 bit signed integer scalar type.
/// @see gtc_type_precision
typedef highp_i64vec1 i64vec1;
/// Default precision 64 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_i64vec2 i64vec2;
/// Default precision 64 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_i64vec3 i64vec3;
/// Default precision 64 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_i64vec4 i64vec4;
#endif
/////////////////////////////
// Unsigned int vector types
/// Low precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 lowp_uint8;
/// Low precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 lowp_uint16;
/// Low precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 lowp_uint32;
/// Low precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 lowp_uint64;
/// Low precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 lowp_uint8_t;
/// Low precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 lowp_uint16_t;
/// Low precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 lowp_uint32_t;
/// Low precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 lowp_uint64_t;
/// Low precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 lowp_u8;
/// Low precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 lowp_u16;
/// Low precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 lowp_u32;
/// Low precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 lowp_u64;
/// Medium precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 mediump_uint8;
/// Medium precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 mediump_uint16;
/// Medium precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 mediump_uint32;
/// Medium precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 mediump_uint64;
/// Medium precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 mediump_uint8_t;
/// Medium precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 mediump_uint16_t;
/// Medium precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 mediump_uint32_t;
/// Medium precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 mediump_uint64_t;
/// Medium precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 mediump_u8;
/// Medium precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 mediump_u16;
/// Medium precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 mediump_u32;
/// Medium precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 mediump_u64;
/// Medium precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 highp_uint8;
/// Medium precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 highp_uint16;
/// Medium precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 highp_uint32;
/// Medium precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 highp_uint64;
/// Medium precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 highp_uint8_t;
/// Medium precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 highp_uint16_t;
/// Medium precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 highp_uint32_t;
/// Medium precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 highp_uint64_t;
/// Medium precision 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 highp_u8;
/// Medium precision 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 highp_u16;
/// Medium precision 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 highp_u32;
/// Medium precision 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 highp_u64;
/// 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 uint8;
/// 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 uint16;
/// 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 uint32;
/// 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 uint64;
#if GLM_HAS_EXTENDED_INTEGER_TYPE
using std::uint8_t;
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
#else
/// 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 uint8_t;
/// 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 uint16_t;
/// 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 uint32_t;
/// 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 uint64_t;
#endif
/// 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 u8;
/// 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 u16;
/// 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 u32;
/// 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 u64;
/// Low precision 8 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u8, lowp> lowp_u8vec1;
/// Low precision 8 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u8, lowp> lowp_u8vec2;
/// Low precision 8 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u8, lowp> lowp_u8vec3;
/// Low precision 8 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u8, lowp> lowp_u8vec4;
/// Medium precision 8 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u8, mediump> mediump_u8vec1;
/// Medium precision 8 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u8, mediump> mediump_u8vec2;
/// Medium precision 8 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u8, mediump> mediump_u8vec3;
/// Medium precision 8 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u8, mediump> mediump_u8vec4;
/// High precision 8 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u8, highp> highp_u8vec1;
/// High precision 8 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u8, highp> highp_u8vec2;
/// High precision 8 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u8, highp> highp_u8vec3;
/// High precision 8 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u8, highp> highp_u8vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_u8vec1 u8vec1;
typedef lowp_u8vec2 u8vec2;
typedef lowp_u8vec3 u8vec3;
typedef lowp_u8vec4 u8vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_u8vec1 u8vec1;
typedef mediump_u8vec2 u8vec2;
typedef mediump_u8vec3 u8vec3;
typedef mediump_u8vec4 u8vec4;
#else
/// Default precision 8 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef highp_u8vec1 u8vec1;
/// Default precision 8 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_u8vec2 u8vec2;
/// Default precision 8 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_u8vec3 u8vec3;
/// Default precision 8 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_u8vec4 u8vec4;
#endif
/// Low precision 16 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u16, lowp> lowp_u16vec1;
/// Low precision 16 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u16, lowp> lowp_u16vec2;
/// Low precision 16 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u16, lowp> lowp_u16vec3;
/// Low precision 16 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u16, lowp> lowp_u16vec4;
/// Medium precision 16 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u16, mediump> mediump_u16vec1;
/// Medium precision 16 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u16, mediump> mediump_u16vec2;
/// Medium precision 16 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u16, mediump> mediump_u16vec3;
/// Medium precision 16 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u16, mediump> mediump_u16vec4;
/// High precision 16 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u16, highp> highp_u16vec1;
/// High precision 16 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u16, highp> highp_u16vec2;
/// High precision 16 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u16, highp> highp_u16vec3;
/// High precision 16 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u16, highp> highp_u16vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_u16vec1 u16vec1;
typedef lowp_u16vec2 u16vec2;
typedef lowp_u16vec3 u16vec3;
typedef lowp_u16vec4 u16vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_u16vec1 u16vec1;
typedef mediump_u16vec2 u16vec2;
typedef mediump_u16vec3 u16vec3;
typedef mediump_u16vec4 u16vec4;
#else
/// Default precision 16 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef highp_u16vec1 u16vec1;
/// Default precision 16 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_u16vec2 u16vec2;
/// Default precision 16 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_u16vec3 u16vec3;
/// Default precision 16 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_u16vec4 u16vec4;
#endif
/// Low precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u32, lowp> lowp_u32vec1;
/// Low precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u32, lowp> lowp_u32vec2;
/// Low precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u32, lowp> lowp_u32vec3;
/// Low precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u32, lowp> lowp_u32vec4;
/// Medium precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u32, mediump> mediump_u32vec1;
/// Medium precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u32, mediump> mediump_u32vec2;
/// Medium precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u32, mediump> mediump_u32vec3;
/// Medium precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u32, mediump> mediump_u32vec4;
/// High precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u32, highp> highp_u32vec1;
/// High precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u32, highp> highp_u32vec2;
/// High precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u32, highp> highp_u32vec3;
/// High precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u32, highp> highp_u32vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_u32vec1 u32vec1;
typedef lowp_u32vec2 u32vec2;
typedef lowp_u32vec3 u32vec3;
typedef lowp_u32vec4 u32vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_u32vec1 u32vec1;
typedef mediump_u32vec2 u32vec2;
typedef mediump_u32vec3 u32vec3;
typedef mediump_u32vec4 u32vec4;
#else
/// Default precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef highp_u32vec1 u32vec1;
/// Default precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_u32vec2 u32vec2;
/// Default precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_u32vec3 u32vec3;
/// Default precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_u32vec4 u32vec4;
#endif
/// Low precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u32, lowp> lowp_u32vec1;
/// Low precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u32, lowp> lowp_u32vec2;
/// Low precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u32, lowp> lowp_u32vec3;
/// Low precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u32, lowp> lowp_u32vec4;
/// Medium precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u32, mediump> mediump_u32vec1;
/// Medium precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u32, mediump> mediump_u32vec2;
/// Medium precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u32, mediump> mediump_u32vec3;
/// Medium precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u32, mediump> mediump_u32vec4;
/// High precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u32, highp> highp_u32vec1;
/// High precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u32, highp> highp_u32vec2;
/// High precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u32, highp> highp_u32vec3;
/// High precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u32, highp> highp_u32vec4;
#if(defined(GLM_PRECISION_LOWP_INT))
typedef lowp_u32vec1 u32vec1;
typedef lowp_u32vec2 u32vec2;
typedef lowp_u32vec3 u32vec3;
typedef lowp_u32vec4 u32vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_INT))
typedef mediump_u32vec1 u32vec1;
typedef mediump_u32vec2 u32vec2;
typedef mediump_u32vec3 u32vec3;
typedef mediump_u32vec4 u32vec4;
#else
/// Default precision 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef highp_u32vec1 u32vec1;
/// Default precision 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_u32vec2 u32vec2;
/// Default precision 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_u32vec3 u32vec3;
/// Default precision 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_u32vec4 u32vec4;
#endif
/// Low precision 64 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u64, lowp> lowp_u64vec1;
/// Low precision 64 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u64, lowp> lowp_u64vec2;
/// Low precision 64 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u64, lowp> lowp_u64vec3;
/// Low precision 64 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u64, lowp> lowp_u64vec4;
/// Medium precision 64 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u64, mediump> mediump_u64vec1;
/// Medium precision 64 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u64, mediump> mediump_u64vec2;
/// Medium precision 64 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u64, mediump> mediump_u64vec3;
/// Medium precision 64 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u64, mediump> mediump_u64vec4;
/// High precision 64 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef tvec1<u64, highp> highp_u64vec1;
/// High precision 64 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef tvec2<u64, highp> highp_u64vec2;
/// High precision 64 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef tvec3<u64, highp> highp_u64vec3;
/// High precision 64 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef tvec4<u64, highp> highp_u64vec4;
#if(defined(GLM_PRECISION_LOWP_UINT))
typedef lowp_u64vec1 u64vec1;
typedef lowp_u64vec2 u64vec2;
typedef lowp_u64vec3 u64vec3;
typedef lowp_u64vec4 u64vec4;
#elif(defined(GLM_PRECISION_MEDIUMP_UINT))
typedef mediump_u64vec1 u64vec1;
typedef mediump_u64vec2 u64vec2;
typedef mediump_u64vec3 u64vec3;
typedef mediump_u64vec4 u64vec4;
#else
/// Default precision 64 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef highp_u64vec1 u64vec1;
/// Default precision 64 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef highp_u64vec2 u64vec2;
/// Default precision 64 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef highp_u64vec3 u64vec3;
/// Default precision 64 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef highp_u64vec4 u64vec4;
#endif
//////////////////////
// Float vector types
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 lowp_float32;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 lowp_float64;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 lowp_float32_t;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 lowp_float64_t;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef float32 lowp_f32;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef float64 lowp_f64;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 lowp_float32;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 lowp_float64;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 lowp_float32_t;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 lowp_float64_t;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef float32 lowp_f32;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef float64 lowp_f64;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 lowp_float32;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 lowp_float64;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 lowp_float32_t;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 lowp_float64_t;
/// Low 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef float32 lowp_f32;
/// Low 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef float64 lowp_f64;
/// Medium 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 mediump_float32;
/// Medium 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 mediump_float64;
/// Medium 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 mediump_float32_t;
/// Medium 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 mediump_float64_t;
/// Medium 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef float32 mediump_f32;
/// Medium 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef float64 mediump_f64;
/// High 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 highp_float32;
/// High 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 highp_float64;
/// High 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 highp_float32_t;
/// High 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 highp_float64_t;
/// High 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef float32 highp_f32;
/// High 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef float64 highp_f64;
#if(defined(GLM_PRECISION_LOWP_FLOAT))
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef lowp_float32 float32;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef lowp_float64 float64;
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef lowp_float32_t float32_t;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef lowp_float64_t float64_t;
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef lowp_f32 f32;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef lowp_f64 f64;
#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT))
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef mediump_float32 float32;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef mediump_float64 float64;
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef mediump_float32 float32_t;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef mediump_float64 float64_t;
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef mediump_float32 f32;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef mediump_float64 f64;
#else//(defined(GLM_PRECISION_HIGHP_FLOAT))
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef highp_float32 float32;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef highp_float64 float64;
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef highp_float32_t float32_t;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef highp_float64_t float64_t;
/// Default 32 bit single-precision floating-point scalar.
/// @see gtc_type_precision
typedef highp_float32_t f32;
/// Default 64 bit double-precision floating-point scalar.
/// @see gtc_type_precision
typedef highp_float64_t f64;
#endif
/// Low single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<float, lowp> lowp_vec1;
/// Low single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<float, lowp> lowp_vec2;
/// Low single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<float, lowp> lowp_vec3;
/// Low single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<float, lowp> lowp_vec4;
/// Low single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<float, lowp> lowp_fvec1;
/// Low single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<float, lowp> lowp_fvec2;
/// Low single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<float, lowp> lowp_fvec3;
/// Low single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<float, lowp> lowp_fvec4;
/// Medium single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<float, mediump> mediump_vec1;
/// Medium Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<float, mediump> mediump_vec2;
/// Medium Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<float, mediump> mediump_vec3;
/// Medium Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<float, mediump> mediump_vec4;
/// Medium single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<float, mediump> mediump_fvec1;
/// Medium Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<float, mediump> mediump_fvec2;
/// Medium Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<float, mediump> mediump_fvec3;
/// Medium Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<float, mediump> mediump_fvec4;
/// High single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<float, highp> highp_vec1;
/// High Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<float, highp> highp_vec2;
/// High Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<float, highp> highp_vec3;
/// High Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<float, highp> highp_vec4;
/// High single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<float, highp> highp_fvec1;
/// High Single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<float, highp> highp_fvec2;
/// High Single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<float, highp> highp_fvec3;
/// High Single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<float, highp> highp_fvec4;
/// Low single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<f32, lowp> lowp_f32vec1;
/// Low single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<f32, lowp> lowp_f32vec2;
/// Low single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<f32, lowp> lowp_f32vec3;
/// Low single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<f32, lowp> lowp_f32vec4;
/// Medium single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<f32, mediump> mediump_f32vec1;
/// Medium single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<f32, mediump> mediump_f32vec2;
/// Medium single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<f32, mediump> mediump_f32vec3;
/// Medium single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<f32, mediump> mediump_f32vec4;
/// High single-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<f32, highp> highp_f32vec1;
/// High single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<f32, highp> highp_f32vec2;
/// High single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<f32, highp> highp_f32vec3;
/// High single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<f32, highp> highp_f32vec4;
/// Low double-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<f64, lowp> lowp_f64vec1;
/// Low double-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<f64, lowp> lowp_f64vec2;
/// Low double-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<f64, lowp> lowp_f64vec3;
/// Low double-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<f64, lowp> lowp_f64vec4;
/// Medium double-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<f64, mediump> mediump_f64vec1;
/// Medium double-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<f64, mediump> mediump_f64vec2;
/// Medium double-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<f64, mediump> mediump_f64vec3;
/// Medium double-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<f64, mediump> mediump_f64vec4;
/// High double-precision floating-point vector of 1 component.
/// @see gtc_type_precision
typedef tvec1<f64, highp> highp_f64vec1;
/// High double-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef tvec2<f64, highp> highp_f64vec2;
/// High double-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef tvec3<f64, highp> highp_f64vec3;
/// High double-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef tvec4<f64, highp> highp_f64vec4;
//////////////////////
// Float matrix types
/// Low single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef lowp_f32 lowp_fmat1x1;
/// Low single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f32, lowp> lowp_fmat2x2;
/// Low single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f32, lowp> lowp_fmat2x3;
/// Low single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f32, lowp> lowp_fmat2x4;
/// Low single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f32, lowp> lowp_fmat3x2;
/// Low single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f32, lowp> lowp_fmat3x3;
/// Low single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f32, lowp> lowp_fmat3x4;
/// Low single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f32, lowp> lowp_fmat4x2;
/// Low single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f32, lowp> lowp_fmat4x3;
/// Low single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f32, lowp> lowp_fmat4x4;
/// Low single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef lowp_fmat1x1 lowp_fmat1;
/// Low single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef lowp_fmat2x2 lowp_fmat2;
/// Low single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef lowp_fmat3x3 lowp_fmat3;
/// Low single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef lowp_fmat4x4 lowp_fmat4;
/// Medium single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef mediump_f32 mediump_fmat1x1;
/// Medium single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f32, mediump> mediump_fmat2x2;
/// Medium single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f32, mediump> mediump_fmat2x3;
/// Medium single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f32, mediump> mediump_fmat2x4;
/// Medium single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f32, mediump> mediump_fmat3x2;
/// Medium single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f32, mediump> mediump_fmat3x3;
/// Medium single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f32, mediump> mediump_fmat3x4;
/// Medium single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f32, mediump> mediump_fmat4x2;
/// Medium single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f32, mediump> mediump_fmat4x3;
/// Medium single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f32, mediump> mediump_fmat4x4;
/// Medium single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef mediump_fmat1x1 mediump_fmat1;
/// Medium single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mediump_fmat2x2 mediump_fmat2;
/// Medium single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mediump_fmat3x3 mediump_fmat3;
/// Medium single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mediump_fmat4x4 mediump_fmat4;
/// High single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef highp_f32 highp_fmat1x1;
/// High single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f32, highp> highp_fmat2x2;
/// High single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f32, highp> highp_fmat2x3;
/// High single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f32, highp> highp_fmat2x4;
/// High single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f32, highp> highp_fmat3x2;
/// High single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f32, highp> highp_fmat3x3;
/// High single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f32, highp> highp_fmat3x4;
/// High single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f32, highp> highp_fmat4x2;
/// High single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f32, highp> highp_fmat4x3;
/// High single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f32, highp> highp_fmat4x4;
/// High single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef highp_fmat1x1 highp_fmat1;
/// High single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef highp_fmat2x2 highp_fmat2;
/// High single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef highp_fmat3x3 highp_fmat3;
/// High single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef highp_fmat4x4 highp_fmat4;
/// Low single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f32 lowp_f32mat1x1;
/// Low single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f32, lowp> lowp_f32mat2x2;
/// Low single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f32, lowp> lowp_f32mat2x3;
/// Low single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f32, lowp> lowp_f32mat2x4;
/// Low single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f32, lowp> lowp_f32mat3x2;
/// Low single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f32, lowp> lowp_f32mat3x3;
/// Low single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f32, lowp> lowp_f32mat3x4;
/// Low single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f32, lowp> lowp_f32mat4x2;
/// Low single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f32, lowp> lowp_f32mat4x3;
/// Low single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f32, lowp> lowp_f32mat4x4;
/// Low single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef detail::tmat1x1<f32, lowp> lowp_f32mat1;
/// Low single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef lowp_f32mat2x2 lowp_f32mat2;
/// Low single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef lowp_f32mat3x3 lowp_f32mat3;
/// Low single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef lowp_f32mat4x4 lowp_f32mat4;
/// High single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f32 mediump_f32mat1x1;
/// Low single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f32, mediump> mediump_f32mat2x2;
/// Medium single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f32, mediump> mediump_f32mat2x3;
/// Medium single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f32, mediump> mediump_f32mat2x4;
/// Medium single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f32, mediump> mediump_f32mat3x2;
/// Medium single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f32, mediump> mediump_f32mat3x3;
/// Medium single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f32, mediump> mediump_f32mat3x4;
/// Medium single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f32, mediump> mediump_f32mat4x2;
/// Medium single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f32, mediump> mediump_f32mat4x3;
/// Medium single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f32, mediump> mediump_f32mat4x4;
/// Medium single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef detail::tmat1x1<f32, mediump> f32mat1;
/// Medium single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mediump_f32mat2x2 mediump_f32mat2;
/// Medium single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mediump_f32mat3x3 mediump_f32mat3;
/// Medium single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mediump_f32mat4x4 mediump_f32mat4;
/// High single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f32 highp_f32mat1x1;
/// High single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f32, highp> highp_f32mat2x2;
/// High single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f32, highp> highp_f32mat2x3;
/// High single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f32, highp> highp_f32mat2x4;
/// High single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f32, highp> highp_f32mat3x2;
/// High single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f32, highp> highp_f32mat3x3;
/// High single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f32, highp> highp_f32mat3x4;
/// High single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f32, highp> highp_f32mat4x2;
/// High single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f32, highp> highp_f32mat4x3;
/// High single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f32, highp> highp_f32mat4x4;
/// High single-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef detail::tmat1x1<f32, highp> f32mat1;
/// High single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x2 highp_f32mat2;
/// High single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x3 highp_f32mat3;
/// High single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x4 highp_f32mat4;
/// Low double-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f64 lowp_f64mat1x1;
/// Low double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f64, lowp> lowp_f64mat2x2;
/// Low double-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f64, lowp> lowp_f64mat2x3;
/// Low double-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f64, lowp> lowp_f64mat2x4;
/// Low double-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f64, lowp> lowp_f64mat3x2;
/// Low double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f64, lowp> lowp_f64mat3x3;
/// Low double-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f64, lowp> lowp_f64mat3x4;
/// Low double-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f64, lowp> lowp_f64mat4x2;
/// Low double-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f64, lowp> lowp_f64mat4x3;
/// Low double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f64, lowp> lowp_f64mat4x4;
/// Low double-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef lowp_f64mat1x1 lowp_f64mat1;
/// Low double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef lowp_f64mat2x2 lowp_f64mat2;
/// Low double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef lowp_f64mat3x3 lowp_f64mat3;
/// Low double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef lowp_f64mat4x4 lowp_f64mat4;
/// Medium double-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f64 Highp_f64mat1x1;
/// Medium double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f64, mediump> mediump_f64mat2x2;
/// Medium double-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f64, mediump> mediump_f64mat2x3;
/// Medium double-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f64, mediump> mediump_f64mat2x4;
/// Medium double-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f64, mediump> mediump_f64mat3x2;
/// Medium double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f64, mediump> mediump_f64mat3x3;
/// Medium double-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f64, mediump> mediump_f64mat3x4;
/// Medium double-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f64, mediump> mediump_f64mat4x2;
/// Medium double-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f64, mediump> mediump_f64mat4x3;
/// Medium double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f64, mediump> mediump_f64mat4x4;
/// Medium double-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef mediump_f64mat1x1 mediump_f64mat1;
/// Medium double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mediump_f64mat2x2 mediump_f64mat2;
/// Medium double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mediump_f64mat3x3 mediump_f64mat3;
/// Medium double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mediump_f64mat4x4 mediump_f64mat4;
/// High double-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f64 highp_f64mat1x1;
/// High double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef tmat2x2<f64, highp> highp_f64mat2x2;
/// High double-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef tmat2x3<f64, highp> highp_f64mat2x3;
/// High double-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef tmat2x4<f64, highp> highp_f64mat2x4;
/// High double-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef tmat3x2<f64, highp> highp_f64mat3x2;
/// High double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef tmat3x3<f64, highp> highp_f64mat3x3;
/// High double-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef tmat3x4<f64, highp> highp_f64mat3x4;
/// High double-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef tmat4x2<f64, highp> highp_f64mat4x2;
/// High double-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef tmat4x3<f64, highp> highp_f64mat4x3;
/// High double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef tmat4x4<f64, highp> highp_f64mat4x4;
/// High double-precision floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef highp_f64mat1x1 highp_f64mat1;
/// High double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef highp_f64mat2x2 highp_f64mat2;
/// High double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef highp_f64mat3x3 highp_f64mat3;
/// High double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef highp_f64mat4x4 highp_f64mat4;
//////////////////////////
// Quaternion types
/// Low single-precision floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f32, lowp> lowp_f32quat;
/// Low double-precision floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f64, lowp> lowp_f64quat;
/// Medium single-precision floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f32, mediump> mediump_f32quat;
/// Medium double-precision floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f64, mediump> mediump_f64quat;
/// High single-precision floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f32, highp> highp_f32quat;
/// High double-precision floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f64, highp> highp_f64quat;
#if(defined(GLM_PRECISION_LOWP_FLOAT))
typedef lowp_f32vec1 fvec1;
typedef lowp_f32vec2 fvec2;
typedef lowp_f32vec3 fvec3;
typedef lowp_f32vec4 fvec4;
typedef lowp_f32mat2 fmat2;
typedef lowp_f32mat3 fmat3;
typedef lowp_f32mat4 fmat4;
typedef lowp_f32mat2x2 fmat2x2;
typedef lowp_f32mat3x2 fmat3x2;
typedef lowp_f32mat4x2 fmat4x2;
typedef lowp_f32mat2x3 fmat2x3;
typedef lowp_f32mat3x3 fmat3x3;
typedef lowp_f32mat4x3 fmat4x3;
typedef lowp_f32mat2x4 fmat2x4;
typedef lowp_f32mat3x4 fmat3x4;
typedef lowp_f32mat4x4 fmat4x4;
typedef lowp_f32quat fquat;
typedef lowp_f32vec1 f32vec1;
typedef lowp_f32vec2 f32vec2;
typedef lowp_f32vec3 f32vec3;
typedef lowp_f32vec4 f32vec4;
typedef lowp_f32mat2 f32mat2;
typedef lowp_f32mat3 f32mat3;
typedef lowp_f32mat4 f32mat4;
typedef lowp_f32mat2x2 f32mat2x2;
typedef lowp_f32mat3x2 f32mat3x2;
typedef lowp_f32mat4x2 f32mat4x2;
typedef lowp_f32mat2x3 f32mat2x3;
typedef lowp_f32mat3x3 f32mat3x3;
typedef lowp_f32mat4x3 f32mat4x3;
typedef lowp_f32mat2x4 f32mat2x4;
typedef lowp_f32mat3x4 f32mat3x4;
typedef lowp_f32mat4x4 f32mat4x4;
typedef lowp_f32quat f32quat;
#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT))
typedef mediump_f32vec1 fvec1;
typedef mediump_f32vec2 fvec2;
typedef mediump_f32vec3 fvec3;
typedef mediump_f32vec4 fvec4;
typedef mediump_f32mat2 fmat2;
typedef mediump_f32mat3 fmat3;
typedef mediump_f32mat4 fmat4;
typedef mediump_f32mat2x2 fmat2x2;
typedef mediump_f32mat3x2 fmat3x2;
typedef mediump_f32mat4x2 fmat4x2;
typedef mediump_f32mat2x3 fmat2x3;
typedef mediump_f32mat3x3 fmat3x3;
typedef mediump_f32mat4x3 fmat4x3;
typedef mediump_f32mat2x4 fmat2x4;
typedef mediump_f32mat3x4 fmat3x4;
typedef mediump_f32mat4x4 fmat4x4;
typedef mediump_f32quat fquat;
typedef mediump_f32vec1 f32vec1;
typedef mediump_f32vec2 f32vec2;
typedef mediump_f32vec3 f32vec3;
typedef mediump_f32vec4 f32vec4;
typedef mediump_f32mat2 f32mat2;
typedef mediump_f32mat3 f32mat3;
typedef mediump_f32mat4 f32mat4;
typedef mediump_f32mat2x2 f32mat2x2;
typedef mediump_f32mat3x2 f32mat3x2;
typedef mediump_f32mat4x2 f32mat4x2;
typedef mediump_f32mat2x3 f32mat2x3;
typedef mediump_f32mat3x3 f32mat3x3;
typedef mediump_f32mat4x3 f32mat4x3;
typedef mediump_f32mat2x4 f32mat2x4;
typedef mediump_f32mat3x4 f32mat3x4;
typedef mediump_f32mat4x4 f32mat4x4;
typedef mediump_f32quat f32quat;
#else//if(defined(GLM_PRECISION_HIGHP_FLOAT))
/// Default single-precision floating-point vector of 1 components.
/// @see gtc_type_precision
typedef highp_f32vec1 fvec1;
/// Default single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef highp_f32vec2 fvec2;
/// Default single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef highp_f32vec3 fvec3;
/// Default single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef highp_f32vec4 fvec4;
/// Default single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x2 fmat2x2;
/// Default single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x3 fmat2x3;
/// Default single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x4 fmat2x4;
/// Default single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x2 fmat3x2;
/// Default single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x3 fmat3x3;
/// Default single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x4 fmat3x4;
/// Default single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x2 fmat4x2;
/// Default single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x3 fmat4x3;
/// Default single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x4 fmat4x4;
/// Default single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef fmat2x2 fmat2;
/// Default single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef fmat3x3 fmat3;
/// Default single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef fmat4x4 fmat4;
/// Default single-precision floating-point quaternion.
/// @see gtc_type_precision
typedef highp_fquat fquat;
/// Default single-precision floating-point vector of 1 components.
/// @see gtc_type_precision
typedef highp_f32vec1 f32vec1;
/// Default single-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef highp_f32vec2 f32vec2;
/// Default single-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef highp_f32vec3 f32vec3;
/// Default single-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef highp_f32vec4 f32vec4;
/// Default single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x2 f32mat2x2;
/// Default single-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x3 f32mat2x3;
/// Default single-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat2x4 f32mat2x4;
/// Default single-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x2 f32mat3x2;
/// Default single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x3 f32mat3x3;
/// Default single-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat3x4 f32mat3x4;
/// Default single-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x2 f32mat4x2;
/// Default single-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x3 f32mat4x3;
/// Default single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef highp_f32mat4x4 f32mat4x4;
/// Default single-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef f32mat2x2 f32mat2;
/// Default single-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef f32mat3x3 f32mat3;
/// Default single-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef f32mat4x4 f32mat4;
/// Default single-precision floating-point quaternion.
/// @see gtc_type_precision
typedef highp_f32quat f32quat;
#endif
#if(defined(GLM_PRECISION_LOWP_DOUBLE))
typedef lowp_f64vec1 f64vec1;
typedef lowp_f64vec2 f64vec2;
typedef lowp_f64vec3 f64vec3;
typedef lowp_f64vec4 f64vec4;
typedef lowp_f64mat2 f64mat2;
typedef lowp_f64mat3 f64mat3;
typedef lowp_f64mat4 f64mat4;
typedef lowp_f64mat2x2 f64mat2x2;
typedef lowp_f64mat3x2 f64mat3x2;
typedef lowp_f64mat4x2 f64mat4x2;
typedef lowp_f64mat2x3 f64mat2x3;
typedef lowp_f64mat3x3 f64mat3x3;
typedef lowp_f64mat4x3 f64mat4x3;
typedef lowp_f64mat2x4 f64mat2x4;
typedef lowp_f64mat3x4 f64mat3x4;
typedef lowp_f64mat4x4 f64mat4x4;
typedef lowp_f64quat f64quat;
#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE))
typedef mediump_f64vec1 f64vec1;
typedef mediump_f64vec2 f64vec2;
typedef mediump_f64vec3 f64vec3;
typedef mediump_f64vec4 f64vec4;
typedef mediump_f64mat2 f64mat2;
typedef mediump_f64mat3 f64mat3;
typedef mediump_f64mat4 f64mat4;
typedef mediump_f64mat2x2 f64mat2x2;
typedef mediump_f64mat3x2 f64mat3x2;
typedef mediump_f64mat4x2 f64mat4x2;
typedef mediump_f64mat2x3 f64mat2x3;
typedef mediump_f64mat3x3 f64mat3x3;
typedef mediump_f64mat4x3 f64mat4x3;
typedef mediump_f64mat2x4 f64mat2x4;
typedef mediump_f64mat3x4 f64mat3x4;
typedef mediump_f64mat4x4 f64mat4x4;
typedef mediump_f64quat f64quat;
#else
/// Default double-precision floating-point vector of 1 components.
/// @see gtc_type_precision
typedef highp_f64vec1 f64vec1;
/// Default double-precision floating-point vector of 2 components.
/// @see gtc_type_precision
typedef highp_f64vec2 f64vec2;
/// Default double-precision floating-point vector of 3 components.
/// @see gtc_type_precision
typedef highp_f64vec3 f64vec3;
/// Default double-precision floating-point vector of 4 components.
/// @see gtc_type_precision
typedef highp_f64vec4 f64vec4;
/// Default double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef highp_f64mat2x2 f64mat2x2;
/// Default double-precision floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef highp_f64mat2x3 f64mat2x3;
/// Default double-precision floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef highp_f64mat2x4 f64mat2x4;
/// Default double-precision floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef highp_f64mat3x2 f64mat3x2;
/// Default double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef highp_f64mat3x3 f64mat3x3;
/// Default double-precision floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef highp_f64mat3x4 f64mat3x4;
/// Default double-precision floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef highp_f64mat4x2 f64mat4x2;
/// Default double-precision floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef highp_f64mat4x3 f64mat4x3;
/// Default double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef highp_f64mat4x4 f64mat4x4;
/// Default double-precision floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef f64mat2x2 f64mat2;
/// Default double-precision floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef f64mat3x3 f64mat3;
/// Default double-precision floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef f64mat4x4 f64mat4;
/// Default double-precision floating-point quaternion.
/// @see gtc_type_precision
typedef highp_f64quat f64quat;
#endif
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat3x2.hpp | .hpp | 3,056 | 61 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat3x2.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat3x2.hpp"
namespace glm
{
/// 3 columns of 2 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x2<float, lowp> lowp_mat3x2;
/// 3 columns of 2 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x2<float, mediump> mediump_mat3x2;
/// 3 columns of 2 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x2<float, highp> highp_mat3x2;
}//namespace
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/packing.hpp | .hpp | 1,646 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/packing.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_packing.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/trigonometric.hpp | .hpp | 1,658 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/trigonometric.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_trigonometric.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/integer.hpp | .hpp | 1,646 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/integer.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_integer.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat4x2.hpp | .hpp | 3,060 | 61 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat4x2.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat4x2.hpp"
namespace glm
{
/// 4 columns of 2 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x2<float, lowp> lowp_mat4x2;
/// 4 columns of 2 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x2<float, mediump> mediump_mat4x2;
/// 4 columns of 2 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x2<float, highp> highp_mat4x2;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat4x3.hpp | .hpp | 3,060 | 61 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat4x4.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat4x3.hpp"
namespace glm
{
/// 4 columns of 3 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x3<float, lowp> lowp_mat4x3;
/// 4 columns of 3 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x3<float, mediump> mediump_mat4x3;
/// 4 columns of 3 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x3<float, highp> highp_mat4x3;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/exponential.hpp | .hpp | 1,654 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/exponential.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_exponential.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat2x3.hpp | .hpp | 3,059 | 62 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat2x3.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat2x3.hpp"
namespace glm
{
/// 2 columns of 3 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x3<float, lowp> lowp_mat2x3;
/// 2 columns of 3 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x3<float, mediump> mediump_mat2x3;
/// 2 columns of 3 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x3<float, highp> highp_mat2x3;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat3x3.hpp | .hpp | 4,437 | 82 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat3x3.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat3x3.hpp"
namespace glm
{
/// 3 columns of 3 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x3<float, lowp> lowp_mat3;
/// 3 columns of 3 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x3<float, mediump> mediump_mat3;
/// 3 columns of 3 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x3<float, highp> highp_mat3;
/// 3 columns of 3 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x3<float, lowp> lowp_mat3x3;
/// 3 columns of 3 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x3<float, mediump> mediump_mat3x3;
/// 3 columns of 3 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat3x3<float, highp> highp_mat3x3;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat2x2.hpp | .hpp | 4,437 | 82 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat2x2.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat2x2.hpp"
namespace glm
{
/// 2 columns of 2 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x2<float, lowp> lowp_mat2;
/// 2 columns of 2 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x2<float, mediump> mediump_mat2;
/// 2 columns of 2 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x2<float, highp> highp_mat2;
/// 2 columns of 2 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x2<float, lowp> lowp_mat2x2;
/// 2 columns of 2 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x2<float, mediump> mediump_mat2x2;
/// 2 columns of 2 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat2x2<float, highp> highp_mat2x2;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/ext.hpp | .hpp | 5,300 | 144 | ///////////////////////////////////////////////////////////////////////////////////
/// 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 glm/glm.hpp
/// @date 2009-05-01 / 2011-05-16
/// @author Christophe Riccio
///
/// @ref core (Dependence)
///
/// @defgroup gtc GTC Extensions (Stable)
///
/// @brief Functions and types that the GLSL specification doesn't define, but useful to have for a C++ program.
///
/// GTC extensions aim to be stable.
///
/// Even if it's highly unrecommended, it's possible to include all the extensions at once by
/// including <glm/ext.hpp>. Otherwise, each extension needs to be included a specific file.
///
/// @defgroup gtx GTX Extensions (Experimental)
///
/// @brief Functions and types that the GLSL specification doesn't define, but
/// useful to have for a C++ program.
///
/// Experimental extensions are useful functions and types, but the development of
/// their API and functionality is not necessarily stable. They can change
/// substantially between versions. Backwards compatibility is not much of an issue
/// for them.
///
/// Even if it's highly unrecommended, it's possible to include all the extensions
/// at once by including <glm/ext.hpp>. Otherwise, each extension needs to be
/// included a specific file.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_EXT_INCLUDED_DISPLAYED))
# define GLM_MESSAGE_EXT_INCLUDED_DISPLAYED
# pragma message("GLM: All extensions included (not recommanded)")
#endif//GLM_MESSAGES
#include "./gtc/bitfield.hpp"
#include "./gtc/constants.hpp"
#include "./gtc/epsilon.hpp"
#include "./gtc/integer.hpp"
#include "./gtc/matrix_access.hpp"
#include "./gtc/matrix_integer.hpp"
#include "./gtc/matrix_inverse.hpp"
#include "./gtc/matrix_transform.hpp"
#include "./gtc/noise.hpp"
#include "./gtc/packing.hpp"
#include "./gtc/quaternion.hpp"
#include "./gtc/random.hpp"
#include "./gtc/reciprocal.hpp"
#include "./gtc/round.hpp"
#include "./gtc/type_precision.hpp"
#include "./gtc/type_ptr.hpp"
#include "./gtc/ulp.hpp"
#include "./gtc/vec1.hpp"
#include "./gtx/associated_min_max.hpp"
#include "./gtx/bit.hpp"
#include "./gtx/closest_point.hpp"
#include "./gtx/color_space.hpp"
#include "./gtx/color_space_YCoCg.hpp"
#include "./gtx/compatibility.hpp"
#include "./gtx/component_wise.hpp"
#include "./gtx/dual_quaternion.hpp"
#include "./gtx/euler_angles.hpp"
#include "./gtx/extend.hpp"
#include "./gtx/extented_min_max.hpp"
#include "./gtx/fast_exponential.hpp"
#include "./gtx/fast_square_root.hpp"
#include "./gtx/fast_trigonometry.hpp"
#include "./gtx/gradient_paint.hpp"
#include "./gtx/handed_coordinate_space.hpp"
#include "./gtx/integer.hpp"
#include "./gtx/intersect.hpp"
#include "./gtx/log_base.hpp"
#include "./gtx/matrix_cross_product.hpp"
#include "./gtx/matrix_interpolation.hpp"
#include "./gtx/matrix_major_storage.hpp"
#include "./gtx/matrix_operation.hpp"
#include "./gtx/matrix_query.hpp"
#include "./gtx/mixed_product.hpp"
#include "./gtx/norm.hpp"
#include "./gtx/normal.hpp"
#include "./gtx/normalize_dot.hpp"
#include "./gtx/number_precision.hpp"
#include "./gtx/optimum_pow.hpp"
#include "./gtx/orthonormalize.hpp"
#include "./gtx/perpendicular.hpp"
#include "./gtx/polar_coordinates.hpp"
#include "./gtx/projection.hpp"
#include "./gtx/quaternion.hpp"
#include "./gtx/raw_data.hpp"
#include "./gtx/rotate_vector.hpp"
#include "./gtx/spline.hpp"
#include "./gtx/std_based_type.hpp"
#if !(GLM_COMPILER & GLM_COMPILER_CUDA)
# include "./gtx/string_cast.hpp"
#endif
#include "./gtx/transform.hpp"
#include "./gtx/transform2.hpp"
#include "./gtx/type_aligned.hpp"
#include "./gtx/vector_angle.hpp"
#include "./gtx/vector_query.hpp"
#include "./gtx/wrap.hpp"
#if GLM_HAS_TEMPLATE_ALIASES
# include "./gtx/scalar_multiplication.hpp"
#endif
#if GLM_HAS_RANGE_FOR
# include "./gtx/range.hpp"
#endif
#if GLM_ARCH & GLM_ARCH_SSE2
# include "./gtx/simd_vec4.hpp"
# include "./gtx/simd_mat4.hpp"
#endif
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/vec4.hpp | .hpp | 1,640 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/vec4.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_vec4.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/glm.hpp | .hpp | 4,458 | 118 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/glm.hpp
/// @date 2005-01-14 / 2011-10-24
/// @author Christophe Riccio
///
/// @defgroup core GLM Core
///
/// @brief The core of GLM, which implements exactly and only the GLSL specification to the degree possible.
///
/// The GLM core consists of @ref core_types "C++ types that mirror GLSL types" and
/// C++ functions that mirror the GLSL functions. It also includes
/// @ref core_precision "a set of precision-based types" that can be used in the appropriate
/// functions. The C++ types are all based on a basic set of @ref core_template "template types".
///
/// The best documentation for GLM Core is the current GLSL specification,
/// <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.clean.pdf">version 4.2
/// (pdf file)</a>.
///
/// GLM core functionnalities require <glm/glm.hpp> to be included to be used.
///
/// @defgroup core_types Types
///
/// @brief The standard types defined by the specification.
///
/// These types are all typedefs of more generalized, template types. To see the definiton
/// of these template types, go to @ref core_template.
///
/// @ingroup core
///
/// @defgroup core_precision Precision types
///
/// @brief Non-GLSL types that are used to define precision-based types.
///
/// The GLSL language allows the user to define the precision of a particular variable.
/// In OpenGL's GLSL, these precision qualifiers have no effect; they are there for compatibility
/// with OpenGL ES's precision qualifiers, where they @em do have an effect.
///
/// C++ has no language equivalent to precision qualifiers. So GLM provides the next-best thing:
/// a number of typedefs of the @ref core_template that use a particular precision.
///
/// None of these types make any guarantees about the actual precision used.
///
/// @ingroup core
///
/// @defgroup core_template Template types
///
/// @brief The generic template types used as the basis for the core types.
///
/// These types are all templates used to define the actual @ref core_types.
/// These templetes are implementation details of GLM types and should not be used explicitly.
///
/// @ingroup core
///////////////////////////////////////////////////////////////////////////////////
#include "detail/_fixes.hpp"
#pragma once
#include <cmath>
#include <climits>
#include <cfloat>
#include <limits>
#include <cassert>
#include "fwd.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_CORE_INCLUDED_DISPLAYED))
# define GLM_MESSAGE_CORE_INCLUDED_DISPLAYED
# pragma message("GLM: Core library included")
#endif//GLM_MESSAGE
#include "vec2.hpp"
#include "vec3.hpp"
#include "vec4.hpp"
#include "mat2x2.hpp"
#include "mat2x3.hpp"
#include "mat2x4.hpp"
#include "mat3x2.hpp"
#include "mat3x3.hpp"
#include "mat3x4.hpp"
#include "mat4x2.hpp"
#include "mat4x3.hpp"
#include "mat4x4.hpp"
#include "trigonometric.hpp"
#include "exponential.hpp"
#include "common.hpp"
#include "packing.hpp"
#include "geometric.hpp"
#include "matrix.hpp"
#include "vector_relational.hpp"
#include "integer.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/vec2.hpp | .hpp | 1,640 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/vec2.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_vec2.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/mat4x4.hpp | .hpp | 4,437 | 82 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/mat4x4.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/type_mat4x4.hpp"
namespace glm
{
/// 4 columns of 4 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x4<float, lowp> lowp_mat4;
/// 4 columns of 4 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x4<float, mediump> mediump_mat4;
/// 4 columns of 4 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x4<float, highp> highp_mat4;
/// 4 columns of 4 components matrix of low precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x4<float, lowp> lowp_mat4x4;
/// 4 columns of 4 components matrix of medium precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x4<float, mediump> mediump_mat4x4;
/// 4 columns of 4 components matrix of high precision floating-point numbers.
/// There is no guarantee on the actual precision.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
typedef tmat4x4<float, highp> highp_mat4x4;
}//namespace glm
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/vector_relational.hpp | .hpp | 1,666 | 36 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref core
/// @file glm/vector_relational.hpp
/// @date 2013-12-24 / 2013-12-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "detail/func_vector_relational.hpp"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/matrix_operation.hpp | .hpp | 3,818 | 114 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_matrix_operation
/// @file glm/gtx/matrix_operation.hpp
/// @date 2009-08-29 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_operation GLM_GTX_matrix_operation
/// @ingroup gtx
///
/// @brief Build diagonal matrices from vectors.
///
/// <glm/gtx/matrix_operation.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_operation extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_operation
/// @{
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> diagonal2x2(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> diagonal2x3(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> diagonal2x4(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> diagonal3x2(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> diagonal3x3(
tvec3<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> diagonal3x4(
tvec3<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> diagonal4x2(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> diagonal4x3(
tvec3<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> diagonal4x4(
tvec4<T, P> const & v);
/// @}
}//namespace glm
#include "matrix_operation.inl"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/matrix_cross_product.hpp | .hpp | 2,639 | 73 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_matrix_cross_product
/// @file glm/gtx/matrix_cross_product.hpp
/// @date 2005-12-21 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product
/// @ingroup gtx
///
/// @brief Build cross product matrices
///
/// <glm/gtx/matrix_cross_product.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_cross_product extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_cross_product
/// @{
//! Build a cross product matrix.
//! From GLM_GTX_matrix_cross_product extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> matrixCross3(
tvec3<T, P> const & x);
//! Build a cross product matrix.
//! From GLM_GTX_matrix_cross_product extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> matrixCross4(
tvec3<T, P> const & x);
/// @}
}//namespace glm
#include "matrix_cross_product.inl"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/closest_point.hpp | .hpp | 2,653 | 75 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_closest_point
/// @file glm/gtx/closest_point.hpp
/// @date 2005-12-30 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtx_closest_point GLM_GTX_closest_point
/// @ingroup gtx
///
/// @brief Find the point on a straight line which is the closet of a point.
///
/// <glm/gtx/closest_point.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_closest_point extension included")
#endif
namespace glm
{
/// @addtogroup gtx_closest_point
/// @{
/// Find the point on a straight line which is the closet of a point.
/// @see gtx_closest_point
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> closestPointOnLine(
tvec3<T, P> const & point,
tvec3<T, P> const & a,
tvec3<T, P> const & b);
/// 2d lines work as well
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> closestPointOnLine(
tvec2<T, P> const & point,
tvec2<T, P> const & a,
tvec2<T, P> const & b);
/// @}
}// namespace glm
#include "closest_point.inl"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/euler_angles.hpp | .hpp | 5,371 | 157 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_euler_angles
/// @file glm/gtx/euler_angles.hpp
/// @date 2005-12-21 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtc_half_float (dependence)
///
/// @defgroup gtx_euler_angles GLM_GTX_euler_angles
/// @ingroup gtx
///
/// @brief Build matrices from Euler angles.
///
/// <glm/gtx/euler_angles.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_euler_angles extension included")
#endif
namespace glm
{
/// @addtogroup gtx_euler_angles
/// @{
/// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle X.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleX(
T const & angleX);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle Y.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleY(
T const & angleY);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle Z.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleZ(
T const & angleZ);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleXY(
T const & angleX,
T const & angleY);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleYX(
T const & angleY,
T const & angleX);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleXZ(
T const & angleX,
T const & angleZ);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleZX(
T const & angle,
T const & angleX);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleYZ(
T const & angleY,
T const & angleZ);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleZY(
T const & angleZ,
T const & angleY);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> eulerAngleYXZ(
T const & yaw,
T const & pitch,
T const & roll);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> yawPitchRoll(
T const & yaw,
T const & pitch,
T const & roll);
/// Creates a 2D 2 * 2 rotation matrix from an euler angle.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat2x2<T, defaultp> orientate2(T const & angle);
/// Creates a 2D 4 * 4 homogeneous rotation matrix from an euler angle.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL tmat3x3<T, defaultp> orientate3(T const & angle);
/// Creates a 3D 3 * 3 rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> orientate3(tvec3<T, P> const & angles);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> orientate4(tvec3<T, P> const & angles);
/// @}
}//namespace glm
#include "euler_angles.inl"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/matrix_major_storage.hpp | .hpp | 5,082 | 145 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_matrix_major_storage
/// @file glm/gtx/matrix_major_storage.hpp
/// @date 2006-04-19 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_matrix_major_storage GLM_GTX_matrix_major_storage
/// @ingroup gtx
///
/// @brief Build matrices with specific matrix order, row or column
///
/// <glm/gtx/matrix_major_storage.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_major_storage extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_major_storage
/// @{
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> rowMajor2(
tvec2<T, P> const & v1,
tvec2<T, P> const & v2);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> rowMajor2(
tmat2x2<T, P> const & m);
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> rowMajor3(
tvec3<T, P> const & v1,
tvec3<T, P> const & v2,
tvec3<T, P> const & v3);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> rowMajor3(
tmat3x3<T, P> const & m);
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> rowMajor4(
tvec4<T, P> const & v1,
tvec4<T, P> const & v2,
tvec4<T, P> const & v3,
tvec4<T, P> const & v4);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> rowMajor4(
tmat4x4<T, P> const & m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> colMajor2(
tvec2<T, P> const & v1,
tvec2<T, P> const & v2);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> colMajor2(
tmat2x2<T, P> const & m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> colMajor3(
tvec3<T, P> const & v1,
tvec3<T, P> const & v2,
tvec3<T, P> const & v3);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> colMajor3(
tmat3x3<T, P> const & m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> colMajor4(
tvec4<T, P> const & v1,
tvec4<T, P> const & v2,
tvec4<T, P> const & v3,
tvec4<T, P> const & v4);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> colMajor4(
tmat4x4<T, P> const & m);
/// @}
}//namespace glm
#include "matrix_major_storage.inl"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/polar_coordinates.hpp | .hpp | 2,651 | 74 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_polar_coordinates
/// @file glm/gtx/polar_coordinates.hpp
/// @date 2007-03-06 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates
/// @ingroup gtx
///
/// @brief Conversion from Euclidean space to polar space and revert.
///
/// <glm/gtx/polar_coordinates.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_polar_coordinates extension included")
#endif
namespace glm
{
/// @addtogroup gtx_polar_coordinates
/// @{
/// Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude.
///
/// @see gtx_polar_coordinates
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> polar(
tvec3<T, P> const & euclidean);
/// Convert Polar to Euclidean coordinates.
///
/// @see gtx_polar_coordinates
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> euclidean(
tvec2<T, P> const & polar);
/// @}
}//namespace glm
#include "polar_coordinates.inl"
| Unknown |
2D | JaeHyunLee94/mpm2d | external/glm/glm/gtx/quaternion.hpp | .hpp | 6,251 | 215 | ///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// @ref gtx_quaternion
/// @file glm/gtx/quaternion.hpp
/// @date 2005-12-21 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_quaternion GLM_GTX_quaternion
/// @ingroup gtx
///
/// @brief Extented quaternion types and functions
///
/// <glm/gtx/quaternion.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/constants.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/norm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_quaternion extension included")
#endif
namespace glm
{
/// @addtogroup gtx_quaternion
/// @{
//! Compute a cross product between a quaternion and a vector.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> cross(
tquat<T, P> const & q,
tvec3<T, P> const & v);
//! Compute a cross product between a vector and a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> cross(
tvec3<T, P> const & v,
tquat<T, P> const & q);
//! Compute a point on a path according squad equation.
//! q1 and q2 are control points; s1 and s2 are intermediate control points.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> squad(
tquat<T, P> const & q1,
tquat<T, P> const & q2,
tquat<T, P> const & s1,
tquat<T, P> const & s2,
T const & h);
//! Returns an intermediate control point for squad interpolation.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> intermediate(
tquat<T, P> const & prev,
tquat<T, P> const & curr,
tquat<T, P> const & next);
//! Returns a exp of a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> exp(
tquat<T, P> const & q);
//! Returns a log of a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> log(
tquat<T, P> const & q);
/// Returns x raised to the y power.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> pow(
tquat<T, P> const & x,
T const & y);
//! Returns quarternion square root.
///
/// @see gtx_quaternion
//template<typename T, precision P>
//tquat<T, P> sqrt(
// tquat<T, P> const & q);
//! Rotates a 3 components vector by a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> rotate(
tquat<T, P> const & q,
tvec3<T, P> const & v);
/// Rotates a 4 components vector by a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> rotate(
tquat<T, P> const & q,
tvec4<T, P> const & v);
/// Extract the real component of a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T extractRealComponent(
tquat<T, P> const & q);
/// Converts a quaternion to a 3 * 3 matrix.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> toMat3(
tquat<T, P> const & x){return mat3_cast(x);}
/// Converts a quaternion to a 4 * 4 matrix.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> toMat4(
tquat<T, P> const & x){return mat4_cast(x);}
/// Converts a 3 * 3 matrix to a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> toQuat(
tmat3x3<T, P> const & x){return quat_cast(x);}
/// Converts a 4 * 4 matrix to a quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> toQuat(
tmat4x4<T, P> const & x){return quat_cast(x);}
/// Quaternion interpolation using the rotation short path.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> shortMix(
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & a);
/// Quaternion normalized linear interpolation.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> fastMix(
tquat<T, P> const & x,
tquat<T, P> const & y,
T const & a);
/// Compute the rotation between two vectors.
/// param orig vector, needs to be normalized
/// param dest vector, needs to be normalized
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> rotation(
tvec3<T, P> const & orig,
tvec3<T, P> const & dest);
/// Returns the squared length of x.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T length2(tquat<T, P> const & q);
/// @}
}//namespace glm
#include "quaternion.inl"
| Unknown |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.