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 |
|---|---|---|---|---|---|---|---|
3D | mcellteam/mcell | libs/gperftools/src/tests/maybe_threads_unittest.sh | .sh | 3,441 | 80 | #!/bin/sh
# Copyright (c) 2007, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ---
# Author: Craig Silverstein
#
# maybe_threads.cc was written to allow LD_PRELOAD=libtcmalloc.so to
# work even on binaries that were not linked with pthreads. This
# unittest tests that, by running low_level_alloc_unittest with an
# LD_PRELOAD. (low_level_alloc_unittest was chosen because it doesn't
# link in tcmalloc.)
#
# We assume all the .so files are in the same directory as both
# addressmap_unittest and profiler1_unittest. The reason we need
# profiler1_unittest is because it's instrumented to show the directory
# it's "really" in when run without any args. In practice this will either
# be BINDIR, or, when using libtool, BINDIR/.lib.
# We expect BINDIR to be set in the environment.
# If not, we set them to some reasonable values.
BINDIR="${BINDIR:-.}"
if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then
echo "USAGE: $0 [unittest dir]"
echo " By default, unittest_dir=$BINDIR"
exit 1
fi
UNITTEST_DIR=${1:-$BINDIR}
# Figure out the "real" unittest directory. Also holds the .so files.
UNITTEST_DIR=`$UNITTEST_DIR/low_level_alloc_unittest --help 2>&1 \
| awk '{print $2; exit;}' \
| xargs dirname`
# Figure out where libtcmalloc lives. It should be in UNITTEST_DIR,
# but with libtool it might be in a subdir.
if [ -r "$UNITTEST_DIR/libtcmalloc_minimal.so" ]; then
LIB_PATH="$UNITTEST_DIR/libtcmalloc_minimal.so"
elif [ -r "$UNITTEST_DIR/.libs/libtcmalloc_minimal.so" ]; then
LIB_PATH="$UNITTEST_DIR/.libs/libtcmalloc_minimal.so"
elif [ -r "$UNITTEST_DIR/libtcmalloc_minimal.dylib" ]; then # for os x
LIB_PATH="$UNITTEST_DIR/libtcmalloc_minimal.dylib"
elif [ -r "$UNITTEST_DIR/.libs/libtcmalloc_minimal.dylib" ]; then
LIB_PATH="$UNITTEST_DIR/.libs/libtcmalloc_minimal.dylib"
else
echo "Cannot run $0: cannot find libtcmalloc_minimal.so"
exit 2
fi
LD_PRELOAD="$LIB_PATH" $UNITTEST_DIR/low_level_alloc_unittest
| Shell |
3D | mcellteam/mcell | libs/gperftools/src/tests/heap-checker_unittest.cc | .cc | 48,766 | 1,539 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Maxim Lifantsev
//
// Running:
// ./heap-checker_unittest
//
// If the unittest crashes because it can't find pprof, try:
// PPROF_PATH=/usr/local/someplace/bin/pprof ./heap-checker_unittest
//
// To test that the whole-program heap checker will actually cause a leak, try:
// HEAPCHECK_TEST_LEAK= ./heap-checker_unittest
// HEAPCHECK_TEST_LOOP_LEAK= ./heap-checker_unittest
//
// Note: Both of the above commands *should* abort with an error message.
// CAVEAT: Do not use vector<> and string on-heap objects in this test,
// otherwise the test can sometimes fail for tricky leak checks
// when we want some allocated object not to be found live by the heap checker.
// This can happen with memory allocators like tcmalloc that can allocate
// heap objects back to back without any book-keeping data in between.
// What happens is that end-of-storage pointers of a live vector
// (or a string depending on the STL implementation used)
// can happen to point to that other heap-allocated
// object that is not reachable otherwise and that
// we don't want to be reachable.
//
// The implication of this for real leak checking
// is just one more chance for the liveness flood to be inexact
// (see the comment in our .h file).
#include "config_for_unittests.h"
#ifdef HAVE_POLL_H
#include <poll.h>
#endif
#if defined HAVE_STDINT_H
#include <stdint.h> // to get uint16_t (ISO naming madness)
#elif defined HAVE_INTTYPES_H
#include <inttypes.h> // another place uint16_t might be defined
#endif
#include <sys/types.h>
#include <stdlib.h>
#include <errno.h> // errno
#ifdef HAVE_UNISTD_H
#include <unistd.h> // for sleep(), geteuid()
#endif
#ifdef HAVE_MMAP
#include <sys/mman.h>
#endif
#include <fcntl.h> // for open(), close()
#ifdef HAVE_EXECINFO_H
#include <execinfo.h> // backtrace
#endif
#ifdef HAVE_GRP_H
#include <grp.h> // getgrent, getgrnam
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <algorithm>
#include <iostream> // for cout
#include <iomanip> // for hex
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/commandlineflags.h"
#include "base/googleinit.h"
#include "base/logging.h"
#include "base/commandlineflags.h"
#include "base/thread_lister.h"
#include <gperftools/heap-checker.h>
#include "memory_region_map.h"
#include <gperftools/malloc_extension.h>
#include <gperftools/stacktrace.h>
// On systems (like freebsd) that don't define MAP_ANONYMOUS, use the old
// form of the name instead.
#ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS MAP_ANON
#endif
using namespace std;
// ========================================================================= //
// TODO(maxim): write a shell script to test that these indeed crash us
// (i.e. we do detect leaks)
// Maybe add more such crash tests.
DEFINE_bool(test_leak,
EnvToBool("HEAP_CHECKER_TEST_TEST_LEAK", false),
"If should cause a leak crash");
DEFINE_bool(test_loop_leak,
EnvToBool("HEAP_CHECKER_TEST_TEST_LOOP_LEAK", false),
"If should cause a looped leak crash");
DEFINE_bool(test_register_leak,
EnvToBool("HEAP_CHECKER_TEST_TEST_REGISTER_LEAK", false),
"If should cause a leak crash by hiding a pointer "
"that is only in a register");
DEFINE_bool(test_cancel_global_check,
EnvToBool("HEAP_CHECKER_TEST_TEST_CANCEL_GLOBAL_CHECK", false),
"If should test HeapLeakChecker::CancelGlobalCheck "
"when --test_leak or --test_loop_leak are given; "
"the test should not fail then");
DEFINE_bool(maybe_stripped,
EnvToBool("HEAP_CHECKER_TEST_MAYBE_STRIPPED", true),
"If we think we can be a stripped binary");
DEFINE_bool(interfering_threads,
EnvToBool("HEAP_CHECKER_TEST_INTERFERING_THREADS", true),
"If we should use threads trying "
"to interfere with leak checking");
DEFINE_bool(hoarding_threads,
EnvToBool("HEAP_CHECKER_TEST_HOARDING_THREADS", true),
"If threads (usually the manager thread) are known "
"to retain some old state in their global buffers, "
"so that it's hard to force leaks when threads are around");
// TODO(maxim): Chage the default to false
// when the standard environment used NTPL threads:
// they do not seem to have this problem.
DEFINE_bool(no_threads,
EnvToBool("HEAP_CHECKER_TEST_NO_THREADS", false),
"If we should not use any threads");
// This is used so we can make can_create_leaks_reliably true
// for any pthread implementation and test with that.
DECLARE_int64(heap_check_max_pointer_offset); // heap-checker.cc
DECLARE_string(heap_check); // in heap-checker.cc
#define WARN_IF(cond, msg) LOG_IF(WARNING, cond, msg)
// This is an evil macro! Be very careful using it...
#undef VLOG // and we start by evilling overriding logging.h VLOG
#define VLOG(lvl) if (FLAGS_verbose >= (lvl)) cout << "\n"
// This is, likewise, evil
#define LOGF VLOG(INFO)
static void RunHeapBusyThreads(); // below
class Closure {
public:
virtual ~Closure() { }
virtual void Run() = 0;
};
class Callback0 : public Closure {
public:
typedef void (*FunctionSignature)();
inline Callback0(FunctionSignature f) : f_(f) {}
virtual void Run() { (*f_)(); delete this; }
private:
FunctionSignature f_;
};
template <class P1> class Callback1 : public Closure {
public:
typedef void (*FunctionSignature)(P1);
inline Callback1<P1>(FunctionSignature f, P1 p1) : f_(f), p1_(p1) {}
virtual void Run() { (*f_)(p1_); delete this; }
private:
FunctionSignature f_;
P1 p1_;
};
template <class P1, class P2> class Callback2 : public Closure {
public:
typedef void (*FunctionSignature)(P1,P2);
inline Callback2<P1,P2>(FunctionSignature f, P1 p1, P2 p2) : f_(f), p1_(p1), p2_(p2) {}
virtual void Run() { (*f_)(p1_, p2_); delete this; }
private:
FunctionSignature f_;
P1 p1_;
P2 p2_;
};
inline Callback0* NewCallback(void (*function)()) {
return new Callback0(function);
}
template <class P1>
inline Callback1<P1>* NewCallback(void (*function)(P1), P1 p1) {
return new Callback1<P1>(function, p1);
}
template <class P1, class P2>
inline Callback2<P1,P2>* NewCallback(void (*function)(P1,P2), P1 p1, P2 p2) {
return new Callback2<P1,P2>(function, p1, p2);
}
// Set to true at end of main, so threads know. Not entirely thread-safe!,
// but probably good enough.
static bool g_have_exited_main = false;
// If we can reliably create leaks (i.e. make leaked object
// really unreachable from any global data).
static bool can_create_leaks_reliably = false;
// We use a simple allocation wrapper
// to make sure we wipe out the newly allocated objects
// in case they still happened to contain some pointer data
// accidentally left by the memory allocator.
struct Initialized { };
static Initialized initialized;
void* operator new(size_t size, const Initialized&) {
// Below we use "p = new(initialized) Foo[1];" and "delete[] p;"
// instead of "p = new(initialized) Foo;"
// when we need to delete an allocated object.
void* p = malloc(size);
memset(p, 0, size);
return p;
}
void* operator new[](size_t size, const Initialized&) {
char* p = new char[size];
memset(p, 0, size);
return p;
}
static void DoWipeStack(int n); // defined below
static void WipeStack() { DoWipeStack(20); }
static void Pause() {
poll(NULL, 0, 77); // time for thread activity in HeapBusyThreadBody
// Indirectly test malloc_extension.*:
CHECK(MallocExtension::instance()->VerifyAllMemory());
int blocks;
size_t total;
int histogram[kMallocHistogramSize];
if (MallocExtension::instance()
->MallocMemoryStats(&blocks, &total, histogram) && total != 0) {
VLOG(3) << "Malloc stats: " << blocks << " blocks of "
<< total << " bytes";
for (int i = 0; i < kMallocHistogramSize; ++i) {
if (histogram[i]) {
VLOG(3) << " Malloc histogram at " << i << " : " << histogram[i];
}
}
}
WipeStack(); // e.g. MallocExtension::VerifyAllMemory
// can leave pointers to heap objects on stack
}
// Make gcc think a pointer is "used"
template <class T>
static void Use(T** foo) {
VLOG(2) << "Dummy-using " << static_cast<void*>(*foo) << " at " << foo;
}
// Arbitrary value, but not such that xor'ing with it is likely
// to map one valid pointer to another valid pointer:
static const uintptr_t kHideMask =
static_cast<uintptr_t>(0xF03A5F7BF03A5F7BLL);
// Helpers to hide a pointer from live data traversal.
// We just xor the pointer so that (with high probability)
// it's not a valid address of a heap object anymore.
// Both Hide and UnHide must be executed within RunHidden() below
// to prevent leaving stale data on active stack that can be a pointer
// to a heap object that is not actually reachable via live variables.
// (UnHide might leave heap pointer value for an object
// that will be deallocated but later another object
// can be allocated at the same heap address.)
template <class T>
static void Hide(T** ptr) {
// we cast values, not dereferenced pointers, so no aliasing issues:
*ptr = reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(*ptr) ^ kHideMask);
VLOG(2) << "hid: " << static_cast<void*>(*ptr);
}
template <class T>
static void UnHide(T** ptr) {
VLOG(2) << "unhiding: " << static_cast<void*>(*ptr);
// we cast values, not dereferenced pointers, so no aliasing issues:
*ptr = reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(*ptr) ^ kHideMask);
}
static void LogHidden(const char* message, const void* ptr) {
LOGF << message << " : "
<< ptr << " ^ " << reinterpret_cast<void*>(kHideMask) << endl;
}
// volatile to fool the compiler against inlining the calls to these
void (*volatile run_hidden_ptr)(Closure* c, int n);
void (*volatile wipe_stack_ptr)(int n);
static void DoRunHidden(Closure* c, int n) {
if (n) {
VLOG(10) << "Level " << n << " at " << &n;
(*run_hidden_ptr)(c, n-1);
(*wipe_stack_ptr)(n);
sleep(0); // undo -foptimize-sibling-calls
} else {
c->Run();
}
}
/*static*/ void DoWipeStack(int n) {
VLOG(10) << "Wipe level " << n << " at " << &n;
if (n) {
const int sz = 30;
volatile int arr[sz] ATTRIBUTE_UNUSED;
for (int i = 0; i < sz; ++i) arr[i] = 0;
(*wipe_stack_ptr)(n-1);
sleep(0); // undo -foptimize-sibling-calls
}
}
// This executes closure c several stack frames down from the current one
// and then makes an effort to also wipe out the stack data that was used by
// the closure.
// This way we prevent leak checker from finding any temporary pointers
// of the closure execution on the stack and deciding that
// these pointers (and the pointed objects) are still live.
static void RunHidden(Closure* c) {
DoRunHidden(c, 15);
DoWipeStack(20);
}
static void DoAllocHidden(size_t size, void** ptr) {
void* p = new(initialized) char[size];
Hide(&p);
Use(&p); // use only hidden versions
VLOG(2) << "Allocated hidden " << p << " at " << &p;
*ptr = p; // assign the hidden versions
}
static void* AllocHidden(size_t size) {
void* r;
RunHidden(NewCallback(DoAllocHidden, size, &r));
return r;
}
static void DoDeAllocHidden(void** ptr) {
Use(ptr); // use only hidden versions
void* p = *ptr;
VLOG(2) << "Deallocating hidden " << p;
UnHide(&p);
delete [] reinterpret_cast<char*>(p);
}
static void DeAllocHidden(void** ptr) {
RunHidden(NewCallback(DoDeAllocHidden, ptr));
*ptr = NULL;
Use(ptr);
}
void PreventHeapReclaiming(size_t size) {
#ifdef NDEBUG
if (true) {
static void** no_reclaim_list = NULL;
CHECK(size >= sizeof(void*));
// We can't use malloc_reclaim_memory flag in opt mode as debugallocation.cc
// is not used. Instead we allocate a bunch of heap objects that are
// of the same size as what we are going to leak to ensure that the object
// we are about to leak is not at the same address as some old allocated
// and freed object that might still have pointers leading to it.
for (int i = 0; i < 100; ++i) {
void** p = reinterpret_cast<void**>(new(initialized) char[size]);
p[0] = no_reclaim_list;
no_reclaim_list = p;
}
}
#endif
}
static bool RunSilent(HeapLeakChecker* check,
bool (HeapLeakChecker::* func)()) {
// By default, don't print the 'we detected a leak' message in the
// cases we're expecting a leak (we still print when --v is >= 1).
// This way, the logging output is less confusing: we only print
// "we detected a leak", and how to diagnose it, for *unexpected* leaks.
int32 old_FLAGS_verbose = FLAGS_verbose;
if (!VLOG_IS_ON(1)) // not on a verbose setting
FLAGS_verbose = FATAL; // only log fatal errors
const bool retval = (check->*func)();
FLAGS_verbose = old_FLAGS_verbose;
return retval;
}
#define RUN_SILENT(check, func) RunSilent(&(check), &HeapLeakChecker::func)
enum CheckType { SAME_HEAP, NO_LEAKS };
static void VerifyLeaks(HeapLeakChecker* check, CheckType type,
int leaked_bytes, int leaked_objects) {
WipeStack(); // to help with can_create_leaks_reliably
const bool no_leaks =
type == NO_LEAKS ? RUN_SILENT(*check, BriefNoLeaks)
: RUN_SILENT(*check, BriefSameHeap);
if (can_create_leaks_reliably) {
// these might still fail occasionally, but it should be very rare
CHECK_EQ(no_leaks, false);
CHECK_EQ(check->BytesLeaked(), leaked_bytes);
CHECK_EQ(check->ObjectsLeaked(), leaked_objects);
} else {
WARN_IF(no_leaks != false,
"Expected leaks not found: "
"Some liveness flood must be too optimistic");
}
}
// not deallocates
static void TestHeapLeakCheckerDeathSimple() {
HeapLeakChecker check("death_simple");
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
void* bar = AllocHidden(300);
Use(&bar);
LogHidden("Leaking", foo);
LogHidden("Leaking", bar);
Pause();
VerifyLeaks(&check, NO_LEAKS, 300 + 100 * sizeof(int), 2);
DeAllocHidden(&foo);
DeAllocHidden(&bar);
}
static void MakeDeathLoop(void** arr1, void** arr2) {
PreventHeapReclaiming(2 * sizeof(void*));
void** a1 = new(initialized) void*[2];
void** a2 = new(initialized) void*[2];
a1[1] = reinterpret_cast<void*>(a2);
a2[1] = reinterpret_cast<void*>(a1);
Hide(&a1);
Hide(&a2);
Use(&a1);
Use(&a2);
VLOG(2) << "Made hidden loop at " << &a1 << " to " << arr1;
*arr1 = a1;
*arr2 = a2;
}
// not deallocates two objects linked together
static void TestHeapLeakCheckerDeathLoop() {
HeapLeakChecker check("death_loop");
void* arr1;
void* arr2;
RunHidden(NewCallback(MakeDeathLoop, &arr1, &arr2));
Use(&arr1);
Use(&arr2);
LogHidden("Leaking", arr1);
LogHidden("Leaking", arr2);
Pause();
VerifyLeaks(&check, NO_LEAKS, 4 * sizeof(void*), 2);
DeAllocHidden(&arr1);
DeAllocHidden(&arr2);
}
// deallocates more than allocates
static void TestHeapLeakCheckerDeathInverse() {
void* bar = AllocHidden(250 * sizeof(int));
Use(&bar);
LogHidden("Pre leaking", bar);
Pause();
HeapLeakChecker check("death_inverse");
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
LogHidden("Leaking", foo);
DeAllocHidden(&bar);
Pause();
VerifyLeaks(&check, SAME_HEAP,
100 * static_cast<int64>(sizeof(int)),
1);
DeAllocHidden(&foo);
}
// deallocates more than allocates
static void TestHeapLeakCheckerDeathNoLeaks() {
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
void* bar = AllocHidden(250 * sizeof(int));
Use(&bar);
HeapLeakChecker check("death_noleaks");
DeAllocHidden(&bar);
CHECK_EQ(check.BriefNoLeaks(), true);
DeAllocHidden(&foo);
}
// have less objecs
static void TestHeapLeakCheckerDeathCountLess() {
void* bar1 = AllocHidden(50 * sizeof(int));
Use(&bar1);
void* bar2 = AllocHidden(50 * sizeof(int));
Use(&bar2);
LogHidden("Pre leaking", bar1);
LogHidden("Pre leaking", bar2);
Pause();
HeapLeakChecker check("death_count_less");
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
LogHidden("Leaking", foo);
DeAllocHidden(&bar1);
DeAllocHidden(&bar2);
Pause();
VerifyLeaks(&check, SAME_HEAP,
100 * sizeof(int),
1);
DeAllocHidden(&foo);
}
// have more objecs
static void TestHeapLeakCheckerDeathCountMore() {
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
LogHidden("Pre leaking", foo);
Pause();
HeapLeakChecker check("death_count_more");
void* bar1 = AllocHidden(50 * sizeof(int));
Use(&bar1);
void* bar2 = AllocHidden(50 * sizeof(int));
Use(&bar2);
LogHidden("Leaking", bar1);
LogHidden("Leaking", bar2);
DeAllocHidden(&foo);
Pause();
VerifyLeaks(&check, SAME_HEAP,
100 * sizeof(int),
2);
DeAllocHidden(&bar1);
DeAllocHidden(&bar2);
}
static void TestHiddenPointer() {
int i;
void* foo = &i;
HiddenPointer<void> p(foo);
CHECK_EQ(foo, p.get());
// Confirm pointer doesn't appear to contain a byte sequence
// that == the pointer. We don't really need to test that
// the xor trick itself works, as without it nothing in this
// test suite would work. See the Hide/Unhide/*Hidden* set
// of helper methods.
void **pvoid = reinterpret_cast<void**>(&p);
CHECK_NE(foo, *pvoid);
}
// simple tests that deallocate what they allocated
static void TestHeapLeakChecker() {
{ HeapLeakChecker check("trivial");
int foo = 5;
int* p = &foo;
Use(&p);
Pause();
CHECK(check.BriefSameHeap());
}
Pause();
{ HeapLeakChecker check("simple");
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
void* bar = AllocHidden(200 * sizeof(int));
Use(&bar);
DeAllocHidden(&foo);
DeAllocHidden(&bar);
Pause();
CHECK(check.BriefSameHeap());
}
}
// no false positives
static void TestHeapLeakCheckerNoFalsePositives() {
{ HeapLeakChecker check("trivial_p");
int foo = 5;
int* p = &foo;
Use(&p);
Pause();
CHECK(check.BriefSameHeap());
}
Pause();
{ HeapLeakChecker check("simple_p");
void* foo = AllocHidden(100 * sizeof(int));
Use(&foo);
void* bar = AllocHidden(200 * sizeof(int));
Use(&bar);
DeAllocHidden(&foo);
DeAllocHidden(&bar);
Pause();
CHECK(check.SameHeap());
}
}
// test that we detect leaks when we have same total # of bytes and
// objects, but different individual object sizes
static void TestLeakButTotalsMatch() {
void* bar1 = AllocHidden(240 * sizeof(int));
Use(&bar1);
void* bar2 = AllocHidden(160 * sizeof(int));
Use(&bar2);
LogHidden("Pre leaking", bar1);
LogHidden("Pre leaking", bar2);
Pause();
HeapLeakChecker check("trick");
void* foo1 = AllocHidden(280 * sizeof(int));
Use(&foo1);
void* foo2 = AllocHidden(120 * sizeof(int));
Use(&foo2);
LogHidden("Leaking", foo1);
LogHidden("Leaking", foo2);
DeAllocHidden(&bar1);
DeAllocHidden(&bar2);
Pause();
// foo1 and foo2 leaked
VerifyLeaks(&check, NO_LEAKS, (280+120)*sizeof(int), 2);
DeAllocHidden(&foo1);
DeAllocHidden(&foo2);
}
// no false negatives from pprof
static void TestHeapLeakCheckerDeathTrick() {
void* bar1 = AllocHidden(240 * sizeof(int));
Use(&bar1);
void* bar2 = AllocHidden(160 * sizeof(int));
Use(&bar2);
HeapLeakChecker check("death_trick");
DeAllocHidden(&bar1);
DeAllocHidden(&bar2);
void* foo1 = AllocHidden(280 * sizeof(int));
Use(&foo1);
void* foo2 = AllocHidden(120 * sizeof(int));
Use(&foo2);
// TODO(maxim): use the above if we make pprof work in automated test runs
if (!FLAGS_maybe_stripped) {
CHECK_EQ(RUN_SILENT(check, SameHeap), false);
// pprof checking should catch the leak
} else {
WARN_IF(RUN_SILENT(check, SameHeap) != false,
"death_trick leak is not caught; "
"we must be using a stripped binary");
}
DeAllocHidden(&foo1);
DeAllocHidden(&foo2);
}
// simple leak
static void TransLeaks() {
AllocHidden(1 * sizeof(char));
}
// range-based disabling using Disabler
static void ScopedDisabledLeaks() {
HeapLeakChecker::Disabler disabler;
AllocHidden(3 * sizeof(int));
TransLeaks();
(void)malloc(10); // Direct leak
}
// have different disabled leaks
static void* RunDisabledLeaks(void* a) {
ScopedDisabledLeaks();
return a;
}
// have different disabled leaks inside of a thread
static void ThreadDisabledLeaks() {
if (FLAGS_no_threads) return;
pthread_t tid;
pthread_attr_t attr;
CHECK_EQ(pthread_attr_init(&attr), 0);
CHECK_EQ(pthread_create(&tid, &attr, RunDisabledLeaks, NULL), 0);
void* res;
CHECK_EQ(pthread_join(tid, &res), 0);
}
// different disabled leaks (some in threads)
static void TestHeapLeakCheckerDisabling() {
HeapLeakChecker check("disabling");
RunDisabledLeaks(NULL);
RunDisabledLeaks(NULL);
ThreadDisabledLeaks();
RunDisabledLeaks(NULL);
ThreadDisabledLeaks();
ThreadDisabledLeaks();
Pause();
CHECK(check.SameHeap());
}
typedef set<int> IntSet;
static int some_ints[] = { 1, 2, 3, 21, 22, 23, 24, 25 };
static void DoTestSTLAlloc() {
IntSet* x = new(initialized) IntSet[1];
*x = IntSet(some_ints, some_ints + 6);
for (int i = 0; i < 1000; i++) {
x->insert(i*3);
}
delete [] x;
}
// Check that normal STL usage does not result in a leak report.
// (In particular we test that there's no complex STL's own allocator
// running on top of our allocator with hooks to heap profiler
// that can result in false leak report in this case.)
static void TestSTLAlloc() {
HeapLeakChecker check("stl");
RunHidden(NewCallback(DoTestSTLAlloc));
CHECK_EQ(check.BriefSameHeap(), true);
}
static void DoTestSTLAllocInverse(IntSet** setx) {
IntSet* x = new(initialized) IntSet[1];
*x = IntSet(some_ints, some_ints + 3);
for (int i = 0; i < 100; i++) {
x->insert(i*2);
}
Hide(&x);
*setx = x;
}
static void FreeTestSTLAllocInverse(IntSet** setx) {
IntSet* x = *setx;
UnHide(&x);
delete [] x;
}
// Check that normal leaked STL usage *does* result in a leak report.
// (In particular we test that there's no complex STL's own allocator
// running on top of our allocator with hooks to heap profiler
// that can result in false absence of leak report in this case.)
static void TestSTLAllocInverse() {
HeapLeakChecker check("death_inverse_stl");
IntSet* x;
RunHidden(NewCallback(DoTestSTLAllocInverse, &x));
LogHidden("Leaking", x);
if (can_create_leaks_reliably) {
WipeStack(); // to help with can_create_leaks_reliably
// these might still fail occasionally, but it should be very rare
CHECK_EQ(RUN_SILENT(check, BriefNoLeaks), false);
CHECK_GE(check.BytesLeaked(), 100 * sizeof(int));
CHECK_GE(check.ObjectsLeaked(), 100);
// assumes set<>s are represented by some kind of binary tree
// or something else allocating >=1 heap object per set object
} else {
WARN_IF(RUN_SILENT(check, BriefNoLeaks) != false,
"Expected leaks not found: "
"Some liveness flood must be too optimistic");
}
RunHidden(NewCallback(FreeTestSTLAllocInverse, &x));
}
template<class Alloc>
static void DirectTestSTLAlloc(Alloc allocator, const char* name) {
HeapLeakChecker check((string("direct_stl-") + name).c_str());
static const int kSize = 1000;
typename Alloc::value_type* ptrs[kSize];
for (int i = 0; i < kSize; ++i) {
typename Alloc::value_type* p = allocator.allocate(i*3+1);
HeapLeakChecker::IgnoreObject(p);
// This will crash if p is not known to heap profiler:
// (i.e. STL's "allocator" does not have a direct hook to heap profiler)
HeapLeakChecker::UnIgnoreObject(p);
ptrs[i] = p;
}
for (int i = 0; i < kSize; ++i) {
allocator.deallocate(ptrs[i], i*3+1);
ptrs[i] = NULL;
}
CHECK(check.BriefSameHeap()); // just in case
}
static struct group* grp = NULL;
static const int kKeys = 50;
static pthread_key_t key[kKeys];
static void KeyFree(void* ptr) {
delete [] reinterpret_cast<char*>(ptr);
}
static bool key_init_has_run = false;
static void KeyInit() {
for (int i = 0; i < kKeys; ++i) {
CHECK_EQ(pthread_key_create(&key[i], KeyFree), 0);
VLOG(2) << "pthread key " << i << " : " << key[i];
}
key_init_has_run = true; // needed for a sanity-check
}
// force various C library static and thread-specific allocations
static void TestLibCAllocate() {
CHECK(key_init_has_run);
for (int i = 0; i < kKeys; ++i) {
void* p = pthread_getspecific(key[i]);
if (NULL == p) {
if (i == 0) {
// Test-logging inside threads which (potentially) creates and uses
// thread-local data inside standard C++ library:
VLOG(0) << "Adding pthread-specifics for thread " << pthread_self()
<< " pid " << getpid();
}
p = new(initialized) char[77 + i];
VLOG(2) << "pthread specific " << i << " : " << p;
pthread_setspecific(key[i], p);
}
}
strerror(errno);
const time_t now = time(NULL);
ctime(&now);
#ifdef HAVE_EXECINFO_H
void *stack[1];
backtrace(stack, 1);
#endif
#ifdef HAVE_GRP_H
gid_t gid = getgid();
getgrgid(gid);
if (grp == NULL) grp = getgrent(); // a race condition here is okay
getgrnam(grp->gr_name);
#endif
#ifdef HAVE_PWD_H
getpwuid(geteuid());
#endif
}
// Continuous random heap memory activity to try to disrupt heap checking.
static void* HeapBusyThreadBody(void* a) {
const int thread_num = reinterpret_cast<intptr_t>(a);
VLOG(0) << "A new HeapBusyThread " << thread_num;
TestLibCAllocate();
int user = 0;
// Try to hide ptr from heap checker in a CPU register:
// Here we are just making a best effort to put the only pointer
// to a heap object into a thread register to test
// the thread-register finding machinery in the heap checker.
#if defined(__i386__) && defined(__GNUC__)
register int** ptr asm("esi");
#elif defined(__x86_64__) && defined(__GNUC__)
register int** ptr asm("r15");
#else
register int** ptr;
#endif
ptr = NULL;
typedef set<int> Set;
Set s1;
while (1) {
// TestLibCAllocate() calls libc functions that don't work so well
// after main() has exited. So we just don't do the test then.
if (!g_have_exited_main)
TestLibCAllocate();
if (ptr == NULL) {
ptr = new(initialized) int*[1];
*ptr = new(initialized) int[1];
}
set<int>* s2 = new(initialized) set<int>[1];
s1.insert(random());
s2->insert(*s1.begin());
user += *s2->begin();
**ptr += user;
if (random() % 51 == 0) {
s1.clear();
if (random() % 2 == 0) {
s1.~Set();
new(&s1) Set;
}
}
VLOG(3) << pthread_self() << " (" << getpid() << "): in wait: "
<< ptr << ", " << *ptr << "; " << s1.size();
VLOG(2) << pthread_self() << " (" << getpid() << "): in wait, ptr = "
<< reinterpret_cast<void*>(
reinterpret_cast<uintptr_t>(ptr) ^ kHideMask)
<< "^" << reinterpret_cast<void*>(kHideMask);
if (FLAGS_test_register_leak && thread_num % 5 == 0) {
// Hide the register "ptr" value with an xor mask.
// If one provides --test_register_leak flag, the test should
// (with very high probability) crash on some leak check
// with a leak report (of some x * sizeof(int) + y * sizeof(int*) bytes)
// pointing at the two lines above in this function
// with "new(initialized) int" in them as the allocators
// of the leaked objects.
// CAVEAT: We can't really prevent a compiler to save some
// temporary values of "ptr" on the stack and thus let us find
// the heap objects not via the register.
// Hence it's normal if for certain compilers or optimization modes
// --test_register_leak does not cause a leak crash of the above form
// (this happens e.g. for gcc 4.0.1 in opt mode).
ptr = reinterpret_cast<int **>(
reinterpret_cast<uintptr_t>(ptr) ^ kHideMask);
// busy loop to get the thread interrupted at:
for (int i = 1; i < 10000000; ++i) user += (1 + user * user * 5) / i;
ptr = reinterpret_cast<int **>(
reinterpret_cast<uintptr_t>(ptr) ^ kHideMask);
} else {
poll(NULL, 0, random() % 100);
}
VLOG(2) << pthread_self() << ": continuing";
if (random() % 3 == 0) {
delete [] *ptr;
delete [] ptr;
ptr = NULL;
}
delete [] s2;
}
return a;
}
static void RunHeapBusyThreads() {
KeyInit();
if (!FLAGS_interfering_threads || FLAGS_no_threads) return;
const int n = 17; // make many threads
pthread_t tid;
pthread_attr_t attr;
CHECK_EQ(pthread_attr_init(&attr), 0);
// make them and let them run
for (int i = 0; i < n; ++i) {
VLOG(0) << "Creating extra thread " << i + 1;
CHECK(pthread_create(&tid, &attr, HeapBusyThreadBody,
reinterpret_cast<void*>(i)) == 0);
}
Pause();
Pause();
}
// ========================================================================= //
// This code section is to test that objects that are reachable from global
// variables are not reported as leaks
// as well as that (Un)IgnoreObject work for such objects fine.
// An object making functions:
// returns a "weird" pointer to a new object for which
// it's worth checking that the object is reachable via that pointer.
typedef void* (*ObjMakerFunc)();
static list<ObjMakerFunc> obj_makers; // list of registered object makers
// Helper macro to register an object making function
// 'name' is an identifier of this object maker,
// 'body' is its function body that must declare
// pointer 'p' to the nex object to return.
// Usage example:
// REGISTER_OBJ_MAKER(trivial, int* p = new(initialized) int;)
#define REGISTER_OBJ_MAKER(name, body) \
void* ObjMaker_##name##_() { \
VLOG(1) << "Obj making " << #name; \
body; \
return p; \
} \
static ObjMakerRegistrar maker_reg_##name##__(&ObjMaker_##name##_);
// helper class for REGISTER_OBJ_MAKER
struct ObjMakerRegistrar {
ObjMakerRegistrar(ObjMakerFunc obj_maker) { obj_makers.push_back(obj_maker); }
};
// List of the objects/pointers made with all the obj_makers
// to test reachability via global data pointers during leak checks.
static list<void*>* live_objects = new list<void*>;
// pointer so that it does not get destructed on exit
// Exerciser for one ObjMakerFunc.
static void TestPointerReach(ObjMakerFunc obj_maker) {
HeapLeakChecker::IgnoreObject(obj_maker()); // test IgnoreObject
void* obj = obj_maker();
HeapLeakChecker::IgnoreObject(obj);
HeapLeakChecker::UnIgnoreObject(obj); // test UnIgnoreObject
HeapLeakChecker::IgnoreObject(obj); // not to need deletion for obj
live_objects->push_back(obj_maker()); // test reachability at leak check
}
// Test all ObjMakerFunc registred via REGISTER_OBJ_MAKER.
static void TestObjMakers() {
for (list<ObjMakerFunc>::const_iterator i = obj_makers.begin();
i != obj_makers.end(); ++i) {
TestPointerReach(*i);
TestPointerReach(*i); // a couple more times would not hurt
TestPointerReach(*i);
}
}
// A dummy class to mimic allocation behavior of string-s.
template<class T>
struct Array {
Array() {
size = 3 + random() % 30;
ptr = new(initialized) T[size];
}
~Array() { delete [] ptr; }
Array(const Array& x) {
size = x.size;
ptr = new(initialized) T[size];
for (size_t i = 0; i < size; ++i) {
ptr[i] = x.ptr[i];
}
}
void operator=(const Array& x) {
delete [] ptr;
size = x.size;
ptr = new(initialized) T[size];
for (size_t i = 0; i < size; ++i) {
ptr[i] = x.ptr[i];
}
}
void append(const Array& x) {
T* p = new(initialized) T[size + x.size];
for (size_t i = 0; i < size; ++i) {
p[i] = ptr[i];
}
for (size_t i = 0; i < x.size; ++i) {
p[size+i] = x.ptr[i];
}
size += x.size;
delete [] ptr;
ptr = p;
}
private:
size_t size;
T* ptr;
};
// to test pointers to objects, built-in arrays, string, etc:
REGISTER_OBJ_MAKER(plain, int* p = new(initialized) int;)
REGISTER_OBJ_MAKER(int_array_1, int* p = new(initialized) int[1];)
REGISTER_OBJ_MAKER(int_array, int* p = new(initialized) int[10];)
REGISTER_OBJ_MAKER(string, Array<char>* p = new(initialized) Array<char>();)
REGISTER_OBJ_MAKER(string_array,
Array<char>* p = new(initialized) Array<char>[5];)
REGISTER_OBJ_MAKER(char_array, char* p = new(initialized) char[5];)
REGISTER_OBJ_MAKER(appended_string,
Array<char>* p = new Array<char>();
p->append(Array<char>());
)
REGISTER_OBJ_MAKER(plain_ptr, int** p = new(initialized) int*;)
REGISTER_OBJ_MAKER(linking_ptr,
int** p = new(initialized) int*;
*p = new(initialized) int;
)
// small objects:
REGISTER_OBJ_MAKER(0_sized, void* p = malloc(0);) // 0-sized object (important)
REGISTER_OBJ_MAKER(1_sized, void* p = malloc(1);)
REGISTER_OBJ_MAKER(2_sized, void* p = malloc(2);)
REGISTER_OBJ_MAKER(3_sized, void* p = malloc(3);)
REGISTER_OBJ_MAKER(4_sized, void* p = malloc(4);)
static int set_data[] = { 1, 2, 3, 4, 5, 6, 7, 21, 22, 23, 24, 25, 26, 27 };
static set<int> live_leak_set(set_data, set_data+7);
static const set<int> live_leak_const_set(set_data, set_data+14);
REGISTER_OBJ_MAKER(set,
set<int>* p = new(initialized) set<int>(set_data, set_data + 13);
)
class ClassA {
public:
explicit ClassA(int a) : ptr(NULL) { }
mutable char* ptr;
};
static const ClassA live_leak_mutable(1);
template<class C>
class TClass {
public:
explicit TClass(int a) : ptr(NULL) { }
mutable C val;
mutable C* ptr;
};
static const TClass<Array<char> > live_leak_templ_mutable(1);
class ClassB {
public:
ClassB() { }
char b[7];
virtual void f() { }
virtual ~ClassB() { }
};
class ClassB2 {
public:
ClassB2() { }
char b2[11];
virtual void f2() { }
virtual ~ClassB2() { }
};
class ClassD1 : public ClassB {
char d1[15];
virtual void f() { }
};
class ClassD2 : public ClassB2 {
char d2[19];
virtual void f2() { }
};
class ClassD : public ClassD1, public ClassD2 {
char d[3];
virtual void f() { }
virtual void f2() { }
};
// to test pointers to objects of base subclasses:
REGISTER_OBJ_MAKER(B, ClassB* p = new(initialized) ClassB;)
REGISTER_OBJ_MAKER(D1, ClassD1* p = new(initialized) ClassD1;)
REGISTER_OBJ_MAKER(D2, ClassD2* p = new(initialized) ClassD2;)
REGISTER_OBJ_MAKER(D, ClassD* p = new(initialized) ClassD;)
REGISTER_OBJ_MAKER(D1_as_B, ClassB* p = new(initialized) ClassD1;)
REGISTER_OBJ_MAKER(D2_as_B2, ClassB2* p = new(initialized) ClassD2;)
REGISTER_OBJ_MAKER(D_as_B, ClassB* p = new(initialized) ClassD;)
REGISTER_OBJ_MAKER(D_as_D1, ClassD1* p = new(initialized) ClassD;)
// inside-object pointers:
REGISTER_OBJ_MAKER(D_as_B2, ClassB2* p = new(initialized) ClassD;)
REGISTER_OBJ_MAKER(D_as_D2, ClassD2* p = new(initialized) ClassD;)
class InterfaceA {
public:
virtual void A() = 0;
virtual ~InterfaceA() { }
protected:
InterfaceA() { }
};
class InterfaceB {
public:
virtual void B() = 0;
virtual ~InterfaceB() { }
protected:
InterfaceB() { }
};
class InterfaceC : public InterfaceA {
public:
virtual void C() = 0;
virtual ~InterfaceC() { }
protected:
InterfaceC() { }
};
class ClassMltD1 : public ClassB, public InterfaceB, public InterfaceC {
public:
char d1[11];
virtual void f() { }
virtual void A() { }
virtual void B() { }
virtual void C() { }
};
class ClassMltD2 : public InterfaceA, public InterfaceB, public ClassB {
public:
char d2[15];
virtual void f() { }
virtual void A() { }
virtual void B() { }
};
// to specifically test heap reachability under
// inerface-only multiple inheritance (some use inside-object pointers):
REGISTER_OBJ_MAKER(MltD1, ClassMltD1* p = new(initialized) ClassMltD1;)
REGISTER_OBJ_MAKER(MltD1_as_B, ClassB* p = new(initialized) ClassMltD1;)
REGISTER_OBJ_MAKER(MltD1_as_IA, InterfaceA* p = new(initialized) ClassMltD1;)
REGISTER_OBJ_MAKER(MltD1_as_IB, InterfaceB* p = new(initialized) ClassMltD1;)
REGISTER_OBJ_MAKER(MltD1_as_IC, InterfaceC* p = new(initialized) ClassMltD1;)
REGISTER_OBJ_MAKER(MltD2, ClassMltD2* p = new(initialized) ClassMltD2;)
REGISTER_OBJ_MAKER(MltD2_as_B, ClassB* p = new(initialized) ClassMltD2;)
REGISTER_OBJ_MAKER(MltD2_as_IA, InterfaceA* p = new(initialized) ClassMltD2;)
REGISTER_OBJ_MAKER(MltD2_as_IB, InterfaceB* p = new(initialized) ClassMltD2;)
// to mimic UnicodeString defined in third_party/icu,
// which store a platform-independent-sized refcount in the first
// few bytes and keeps a pointer pointing behind the refcount.
REGISTER_OBJ_MAKER(unicode_string,
char* p = new char[sizeof(uint32) * 10];
p += sizeof(uint32);
)
// similar, but for platform-dependent-sized refcount
REGISTER_OBJ_MAKER(ref_counted,
char* p = new char[sizeof(int) * 20];
p += sizeof(int);
)
struct Nesting {
struct Inner {
Nesting* parent;
Inner(Nesting* p) : parent(p) {}
};
Inner i0;
char n1[5];
Inner i1;
char n2[11];
Inner i2;
char n3[27];
Inner i3;
Nesting() : i0(this), i1(this), i2(this), i3(this) {}
};
// to test inside-object pointers pointing at objects nested into heap objects:
REGISTER_OBJ_MAKER(nesting_i0, Nesting::Inner* p = &((new Nesting())->i0);)
REGISTER_OBJ_MAKER(nesting_i1, Nesting::Inner* p = &((new Nesting())->i1);)
REGISTER_OBJ_MAKER(nesting_i2, Nesting::Inner* p = &((new Nesting())->i2);)
REGISTER_OBJ_MAKER(nesting_i3, Nesting::Inner* p = &((new Nesting())->i3);)
void (* volatile init_forcer)(...);
// allocate many objects reachable from global data
static void TestHeapLeakCheckerLiveness() {
live_leak_mutable.ptr = new(initialized) char[77];
live_leak_templ_mutable.ptr = new(initialized) Array<char>();
live_leak_templ_mutable.val = Array<char>();
// smart compiler may see that live_leak_mutable is not used
// anywhere so .ptr assignment is not used.
//
// We force compiler to assume that it is used by having function
// variable (set to 0 which hopefully won't be known to compiler)
// which gets address of those objects. So compiler has to assume
// that .ptr is used.
if (init_forcer) {
init_forcer(&live_leak_mutable, &live_leak_templ_mutable);
}
TestObjMakers();
}
// ========================================================================= //
// Get address (PC value) following the mmap call into addr_after_mmap_call
static void* Mmapper(uintptr_t* addr_after_mmap_call) {
void* r = mmap(NULL, 100, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
// Get current PC value into addr_after_mmap_call
void* stack[1];
CHECK_EQ(GetStackTrace(stack, 1, 0), 1);
*addr_after_mmap_call = reinterpret_cast<uintptr_t>(stack[0]);
sleep(0); // undo -foptimize-sibling-calls
return r;
}
// On PPC64 the stacktrace returned by GetStatcTrace contains the function
// address from .text segment while function pointers points to ODP entries.
// The following code decodes the ODP to get the actual symbol address.
#if defined(__linux) && defined(__PPC64__) && (_CALL_ELF != 2)
static inline uintptr_t GetFunctionAddress (void* (*func)(uintptr_t*))
{
struct odp_entry_t {
unsigned long int symbol;
unsigned long int toc;
unsigned long int env;
} *odp_entry = reinterpret_cast<odp_entry_t*>(func);
return static_cast<uintptr_t>(odp_entry->symbol);
}
#else
static inline uintptr_t GetFunctionAddress (void* (*func)(uintptr_t*))
{
return reinterpret_cast<uintptr_t>(func);
}
#endif
// to trick complier into preventing inlining
static void* (*mmapper_addr)(uintptr_t* addr) = &Mmapper;
// TODO(maxim): copy/move this to memory_region_map_unittest
// TODO(maxim): expand this test to include mmap64, mremap and sbrk calls.
static void VerifyMemoryRegionMapStackGet() {
uintptr_t caller_addr_limit;
void* addr = (*mmapper_addr)(&caller_addr_limit);
uintptr_t caller = 0;
{ MemoryRegionMap::LockHolder l;
for (MemoryRegionMap::RegionIterator
i = MemoryRegionMap::BeginRegionLocked();
i != MemoryRegionMap::EndRegionLocked(); ++i) {
if (i->start_addr == reinterpret_cast<uintptr_t>(addr)) {
CHECK_EQ(caller, 0);
caller = i->caller();
}
}
}
// caller must point into Mmapper function:
if (!(GetFunctionAddress(mmapper_addr) <= caller &&
caller < caller_addr_limit)) {
LOGF << std::hex << "0x" << caller
<< " does not seem to point into code of function Mmapper at "
<< "0x" << reinterpret_cast<uintptr_t>(mmapper_addr)
<< "! Stack frame collection must be off in MemoryRegionMap!";
LOG(FATAL, "\n");
}
munmap(addr, 100);
}
static void* Mallocer(uintptr_t* addr_after_malloc_call) {
void* r = malloc(100);
sleep(0); // undo -foptimize-sibling-calls
// Get current PC value into addr_after_malloc_call
void* stack[1];
CHECK_EQ(GetStackTrace(stack, 1, 0), 1);
*addr_after_malloc_call = reinterpret_cast<uintptr_t>(stack[0]);
return r;
}
// to trick compiler into preventing inlining
static void* (* volatile mallocer_addr)(uintptr_t* addr) = &Mallocer;
// non-static for friendship with HeapProfiler
// TODO(maxim): expand this test to include
// realloc, calloc, memalign, valloc, pvalloc, new, and new[].
extern void VerifyHeapProfileTableStackGet() {
uintptr_t caller_addr_limit;
void* addr = (*mallocer_addr)(&caller_addr_limit);
uintptr_t caller =
reinterpret_cast<uintptr_t>(HeapLeakChecker::GetAllocCaller(addr));
// caller must point into Mallocer function:
if (!(GetFunctionAddress(mallocer_addr) <= caller &&
caller < caller_addr_limit)) {
LOGF << std::hex << "0x" << caller
<< " does not seem to point into code of function Mallocer at "
<< "0x" << reinterpret_cast<uintptr_t>(mallocer_addr)
<< "! Stack frame collection must be off in heap profiler!";
LOG(FATAL, "\n");
}
free(addr);
}
// ========================================================================= //
static void MakeALeak(void** arr) {
PreventHeapReclaiming(10 * sizeof(int));
void* a = new(initialized) int[10];
Hide(&a);
*arr = a;
}
// Helper to do 'return 0;' inside main(): insted we do 'return Pass();'
static int Pass() {
fprintf(stdout, "PASS\n");
g_have_exited_main = true;
return 0;
}
int main(int argc, char** argv) {
run_hidden_ptr = DoRunHidden;
wipe_stack_ptr = DoWipeStack;
if (!HeapLeakChecker::IsActive()) {
CHECK_EQ(FLAGS_heap_check, "");
LOG(WARNING, "HeapLeakChecker got turned off; we won't test much...");
} else {
VerifyMemoryRegionMapStackGet();
VerifyHeapProfileTableStackGet();
}
KeyInit();
// glibc 2.4, on x86_64 at least, has a lock-ordering bug, which
// means deadlock is possible when one thread calls dl_open at the
// same time another thread is calling dl_iterate_phdr. libunwind
// calls dl_iterate_phdr, and TestLibCAllocate calls dl_open (or the
// various syscalls in it do), at least the first time it's run.
// To avoid the deadlock, we run TestLibCAllocate once before getting
// multi-threaded.
// TODO(csilvers): once libc is fixed, or libunwind can work around it,
// get rid of this early call. We *want* our test to
// find potential problems like this one!
TestLibCAllocate();
if (FLAGS_interfering_threads) {
RunHeapBusyThreads(); // add interference early
}
TestLibCAllocate();
LOGF << "In main(): heap_check=" << FLAGS_heap_check << endl;
CHECK(HeapLeakChecker::NoGlobalLeaks()); // so far, so good
if (FLAGS_test_leak) {
void* arr;
RunHidden(NewCallback(MakeALeak, &arr));
Use(&arr);
LogHidden("Leaking", arr);
if (FLAGS_test_cancel_global_check) {
HeapLeakChecker::CancelGlobalCheck();
} else {
// Verify we can call NoGlobalLeaks repeatedly without deadlocking
HeapLeakChecker::NoGlobalLeaks();
HeapLeakChecker::NoGlobalLeaks();
}
return Pass();
// whole-program leak-check should (with very high probability)
// catch the leak of arr (10 * sizeof(int) bytes)
// (when !FLAGS_test_cancel_global_check)
}
if (FLAGS_test_loop_leak) {
void* arr1;
void* arr2;
RunHidden(NewCallback(MakeDeathLoop, &arr1, &arr2));
Use(&arr1);
Use(&arr2);
LogHidden("Loop leaking", arr1);
LogHidden("Loop leaking", arr2);
if (FLAGS_test_cancel_global_check) {
HeapLeakChecker::CancelGlobalCheck();
} else {
// Verify we can call NoGlobalLeaks repeatedly without deadlocking
HeapLeakChecker::NoGlobalLeaks();
HeapLeakChecker::NoGlobalLeaks();
}
return Pass();
// whole-program leak-check should (with very high probability)
// catch the leak of arr1 and arr2 (4 * sizeof(void*) bytes)
// (when !FLAGS_test_cancel_global_check)
}
if (FLAGS_test_register_leak) {
// make us fail only where the .sh test expects:
Pause();
for (int i = 0; i < 100; ++i) { // give it some time to crash
CHECK(HeapLeakChecker::NoGlobalLeaks());
Pause();
}
return Pass();
}
TestHeapLeakCheckerLiveness();
HeapLeakChecker heap_check("all");
TestHiddenPointer();
TestHeapLeakChecker();
Pause();
TestLeakButTotalsMatch();
Pause();
TestHeapLeakCheckerDeathSimple();
Pause();
TestHeapLeakCheckerDeathLoop();
Pause();
TestHeapLeakCheckerDeathInverse();
Pause();
TestHeapLeakCheckerDeathNoLeaks();
Pause();
TestHeapLeakCheckerDeathCountLess();
Pause();
TestHeapLeakCheckerDeathCountMore();
Pause();
TestHeapLeakCheckerDeathTrick();
Pause();
CHECK(HeapLeakChecker::NoGlobalLeaks()); // so far, so good
TestHeapLeakCheckerNoFalsePositives();
Pause();
TestHeapLeakCheckerDisabling();
Pause();
TestSTLAlloc();
Pause();
TestSTLAllocInverse();
Pause();
// Test that various STL allocators work. Some of these are redundant, but
// we don't know how STL might change in the future. For example,
// http://wiki/Main/StringNeStdString.
#define DTSL(a) { DirectTestSTLAlloc(a, #a); \
Pause(); }
DTSL(std::allocator<char>());
DTSL(std::allocator<int>());
DTSL(std::string().get_allocator());
DTSL(string().get_allocator());
DTSL(vector<int>().get_allocator());
DTSL(vector<double>().get_allocator());
DTSL(vector<vector<int> >().get_allocator());
DTSL(vector<string>().get_allocator());
DTSL((map<string, string>().get_allocator()));
DTSL((map<string, int>().get_allocator()));
DTSL(set<char>().get_allocator());
#undef DTSL
TestLibCAllocate();
Pause();
CHECK(HeapLeakChecker::NoGlobalLeaks()); // so far, so good
Pause();
if (!FLAGS_maybe_stripped) {
CHECK(heap_check.SameHeap());
} else {
WARN_IF(heap_check.SameHeap() != true,
"overall leaks are caught; we must be using a stripped binary");
}
CHECK(HeapLeakChecker::NoGlobalLeaks()); // so far, so good
return Pass();
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/debugallocation_test.sh | .sh | 3,634 | 99 | #!/bin/sh
# Copyright (c) 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ---
# Author: Craig Silverstein
BINDIR="${BINDIR:-.}"
# We expect PPROF_PATH to be set in the environment.
# If not, we set it to some reasonable value
export PPROF_PATH="${PPROF_PATH:-$BINDIR/src/pprof}"
if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then
echo "USAGE: $0 [unittest dir]"
echo " By default, unittest_dir=$BINDIR"
exit 1
fi
DEBUGALLOCATION_TEST="${1:-$BINDIR/debugallocation_test}"
num_failures=0
# Run the i-th death test and make sure the test has the expected
# regexp. We can depend on the first line of the output being
# Expected regex:<regex>
# Evaluates to "done" if we are not actually a death-test (so $1 is
# too big a number, and we can stop). Evaluates to "" otherwise.
# Increments num_failures if the death test does not succeed.
OneDeathTest() {
"$DEBUGALLOCATION_TEST" "$1" 2>&1 | {
regex_line='dummy'
# Normally the regex_line is the first line of output, but not
# always (if tcmalloc itself does any logging to stderr).
while test -n "$regex_line"; do
read regex_line
regex=`expr "$regex_line" : "Expected regex:\(.*\)"`
test -n "$regex" && break # found the regex line
done
test -z "$regex" && echo "done" || grep "$regex" 2>&1
}
}
death_test_num=0 # which death test to run
while :; do # same as 'while true', but more portable
echo -n "Running death test $death_test_num..."
output="`OneDeathTest $death_test_num`"
case $output in
# Empty string means grep didn't find anything.
"") echo "FAILED"; num_failures=`expr $num_failures + 1`;;
"done"*) echo "done with death tests"; break;;
# Any other string means grep found something, like it ought to.
*) echo "OK";;
esac
death_test_num=`expr $death_test_num + 1`
done
# Test the non-death parts of the test too
echo -n "Running non-death tests..."
if "$DEBUGALLOCATION_TEST"; then
echo "OK"
else
echo "FAILED"
num_failures=`expr $num_failures + 1`
fi
if [ "$num_failures" = 0 ]; then
echo "PASS"
else
echo "Failed with $num_failures failures"
fi
exit $num_failures
| Shell |
3D | mcellteam/mcell | libs/gperftools/src/tests/markidle_unittest.cc | .cc | 4,473 | 128 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2003, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Sanjay Ghemawat
//
// MallocExtension::MarkThreadIdle() testing
#include <stdio.h>
#include "config_for_unittests.h"
#include "base/logging.h"
#include <gperftools/malloc_extension.h>
#include "tests/testutil.h" // for RunThread()
// Helper routine to do lots of allocations
static void TestAllocation() {
static const int kNum = 100;
void* ptr[kNum];
for (int size = 8; size <= 65536; size*=2) {
for (int i = 0; i < kNum; i++) {
ptr[i] = malloc(size);
}
for (int i = 0; i < kNum; i++) {
free(ptr[i]);
}
}
}
// Routine that does a bunch of MarkThreadIdle() calls in sequence
// without any intervening allocations
static void MultipleIdleCalls() {
for (int i = 0; i < 4; i++) {
MallocExtension::instance()->MarkThreadIdle();
}
}
// Routine that does a bunch of MarkThreadIdle() calls in sequence
// with intervening allocations
static void MultipleIdleNonIdlePhases() {
for (int i = 0; i < 4; i++) {
TestAllocation();
MallocExtension::instance()->MarkThreadIdle();
}
}
// Get current thread cache usage
static size_t GetTotalThreadCacheSize() {
size_t result;
CHECK(MallocExtension::instance()->GetNumericProperty(
"tcmalloc.current_total_thread_cache_bytes",
&result));
return result;
}
// Check that MarkThreadIdle() actually reduces the amount
// of per-thread memory.
static void TestIdleUsage() {
const size_t original = GetTotalThreadCacheSize();
TestAllocation();
const size_t post_allocation = GetTotalThreadCacheSize();
CHECK_GT(post_allocation, original);
MallocExtension::instance()->MarkThreadIdle();
const size_t post_idle = GetTotalThreadCacheSize();
CHECK_LE(post_idle, original);
// Log after testing because logging can allocate heap memory.
VLOG(0, "Original usage: %" PRIuS "\n", original);
VLOG(0, "Post allocation: %" PRIuS "\n", post_allocation);
VLOG(0, "Post idle: %" PRIuS "\n", post_idle);
}
static void TestTemporarilyIdleUsage() {
const size_t original = MallocExtension::instance()->GetThreadCacheSize();
TestAllocation();
const size_t post_allocation = MallocExtension::instance()->GetThreadCacheSize();
CHECK_GT(post_allocation, original);
MallocExtension::instance()->MarkThreadIdle();
const size_t post_idle = MallocExtension::instance()->GetThreadCacheSize();
CHECK_EQ(post_idle, 0);
// Log after testing because logging can allocate heap memory.
VLOG(0, "Original usage: %" PRIuS "\n", original);
VLOG(0, "Post allocation: %" PRIuS "\n", post_allocation);
VLOG(0, "Post idle: %" PRIuS "\n", post_idle);
}
int main(int argc, char** argv) {
RunThread(&TestIdleUsage);
RunThread(&TestAllocation);
RunThread(&MultipleIdleCalls);
RunThread(&MultipleIdleNonIdlePhases);
RunThread(&TestTemporarilyIdleUsage);
printf("PASS\n");
return 0;
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/tcmalloc_large_unittest.cc | .cc | 4,745 | 139 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Michael Chastain
//
// This is a unit test for large allocations in malloc and friends.
// "Large" means "so large that they overflow the address space".
// For 32 bits, this means allocations near 2^32 bytes and 2^31 bytes.
// For 64 bits, this means allocations near 2^64 bytes and 2^63 bytes.
#include <stddef.h> // for size_t, NULL
#include <stdlib.h> // for malloc, free, realloc
#include <stdio.h>
#include <set> // for set, etc
#include "base/logging.h" // for operator<<, CHECK, etc
using std::set;
// Alloc a size that should always fail.
void TryAllocExpectFail(size_t size) {
void* p1 = malloc(size);
CHECK(p1 == NULL);
void* p2 = malloc(1);
CHECK(p2 != NULL);
void* p3 = realloc(p2, size);
CHECK(p3 == NULL);
free(p2);
}
// Alloc a size that might work and might fail.
// If it does work, touch some pages.
void TryAllocMightFail(size_t size) {
unsigned char* p = static_cast<unsigned char*>(malloc(size));
if ( p != NULL ) {
unsigned char volatile* vp = p; // prevent optimizations
static const size_t kPoints = 1024;
for ( size_t i = 0; i < kPoints; ++i ) {
vp[i * (size / kPoints)] = static_cast<unsigned char>(i);
}
for ( size_t i = 0; i < kPoints; ++i ) {
CHECK(vp[i * (size / kPoints)] == static_cast<unsigned char>(i));
}
vp[size-1] = 'M';
CHECK(vp[size-1] == 'M');
}
free(p);
}
int main (int argc, char** argv) {
// Allocate some 0-byte objects. They better be unique.
// 0 bytes is not large but it exercises some paths related to
// large-allocation code.
{
static const int kZeroTimes = 1024;
printf("Test malloc(0) x %d\n", kZeroTimes);
set<char*> p_set;
for ( int i = 0; i < kZeroTimes; ++i ) {
char* p = new char;
CHECK(p != NULL);
CHECK(p_set.find(p) == p_set.end());
p_set.insert(p_set.end(), p);
}
// Just leak the memory.
}
// Grab some memory so that some later allocations are guaranteed to fail.
printf("Test small malloc\n");
void* p_small = malloc(4*1048576);
CHECK(p_small != NULL);
// Test sizes up near the maximum size_t.
// These allocations test the wrap-around code.
printf("Test malloc(0 - N)\n");
const size_t zero = 0;
static const size_t kMinusNTimes = 16384;
for ( size_t i = 1; i < kMinusNTimes; ++i ) {
TryAllocExpectFail(zero - i);
}
// Test sizes a bit smaller.
// The small malloc above guarantees that all these return NULL.
printf("Test malloc(0 - 1048576 - N)\n");
static const size_t kMinusMBMinusNTimes = 16384;
for ( size_t i = 0; i < kMinusMBMinusNTimes; ++i) {
TryAllocExpectFail(zero - 1048576 - i);
}
// Test sizes at half of size_t.
// These might or might not fail to allocate.
printf("Test malloc(max/2 +- N)\n");
static const size_t kHalfPlusMinusTimes = 64;
const size_t half = (zero - 2) / 2 + 1;
for ( size_t i = 0; i < kHalfPlusMinusTimes; ++i) {
TryAllocMightFail(half - i);
TryAllocMightFail(half + i);
}
printf("PASS\n");
return 0;
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/getpc_test.cc | .cc | 4,762 | 124 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Craig Silverstein
//
// This verifies that GetPC works correctly. This test uses a minimum
// of Google infrastructure, to make it very easy to port to various
// O/Ses and CPUs and test that GetPC is working.
#include "config.h"
#include "getpc.h" // should be first to get the _GNU_SOURCE dfn
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h> // for setitimer
// Needs to be volatile so compiler doesn't try to optimize it away
static volatile void* getpc_retval = NULL; // what GetPC returns
static volatile bool prof_handler_called = false;
static void prof_handler(int sig, siginfo_t*, void* signal_ucontext) {
if (!prof_handler_called)
getpc_retval = GetPC(*reinterpret_cast<ucontext_t*>(signal_ucontext));
prof_handler_called = true; // only store the retval once
}
static void RoutineCallingTheSignal() {
struct sigaction sa;
sa.sa_sigaction = prof_handler;
sa.sa_flags = SA_RESTART | SA_SIGINFO;
sigemptyset(&sa.sa_mask);
if (sigaction(SIGPROF, &sa, NULL) != 0) {
perror("sigaction");
exit(1);
}
struct itimerval timer;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 1000;
timer.it_value = timer.it_interval;
setitimer(ITIMER_PROF, &timer, 0);
// Now we need to do some work for a while, that doesn't call any
// other functions, so we can be guaranteed that when the SIGPROF
// fires, we're the routine executing.
int r = 0;
for (int i = 0; !prof_handler_called; ++i) {
for (int j = 0; j < i; j++) {
r ^= i;
r <<= 1;
r ^= j;
r >>= 1;
}
}
// Now make sure the above loop doesn't get optimized out
srand(r);
}
// This is an upper bound of how many bytes the instructions for
// RoutineCallingTheSignal might be. There's probably a more
// principled way to do this, but I don't know how portable it would be.
// (The function is 372 bytes when compiled with -g on Mac OS X 10.4.
// I can imagine it would be even bigger in 64-bit architectures.)
const int kRoutineSize = 512 * sizeof(void*)/4; // allow 1024 for 64-bit
int main(int argc, char** argv) {
RoutineCallingTheSignal();
// Annoyingly, C++ disallows casting pointer-to-function to
// pointer-to-object, so we use a C-style cast instead.
char* expected = (char*)&RoutineCallingTheSignal;
char* actual = (char*)getpc_retval;
// For ia64, ppc64v1, and parisc64, the function pointer is actually
// a struct. For instance, ia64's dl-fptr.h:
// struct fdesc { /* An FDESC is a function descriptor. */
// ElfW(Addr) ip; /* code entry point */
// ElfW(Addr) gp; /* global pointer */
// };
// We want the code entry point.
// NOTE: ppc64 ELFv2 (Little Endian) does not have function pointers
#if defined(__ia64) || \
(defined(__powerpc64__) && _CALL_ELF != 2)
expected = ((char**)expected)[0]; // this is "ip"
#endif
if (actual < expected || actual > expected + kRoutineSize) {
printf("Test FAILED: actual PC: %p, expected PC: %p\n", actual, expected);
return 1;
} else {
printf("PASS\n");
return 0;
}
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/packed-cache_test.cc | .cc | 2,747 | 83 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Geoff Pike
#include <stdio.h>
#include "base/logging.h"
#include "packed-cache-inl.h"
static const int kHashbits = PackedCache<20>::kHashbits;
template <int kKeybits>
static size_t MustGet(const PackedCache<kKeybits>& cache, uintptr_t key) {
uint32 rv;
CHECK(cache.TryGet(key, &rv));
return rv;
}
template <int kKeybits>
static size_t Has(const PackedCache<kKeybits>& cache, uintptr_t key) {
uint32 dummy;
return cache.TryGet(key, &dummy);
}
// A basic sanity test.
void PackedCacheTest_basic() {
PackedCache<20> cache;
CHECK(!Has(cache, 0));
cache.Put(0, 17);
CHECK(Has(cache, 0));
CHECK_EQ(MustGet(cache, 0), 17);
cache.Put(19, 99);
CHECK_EQ(MustGet(cache, 0), 17);
CHECK_EQ(MustGet(cache, 19), 99);
// Knock <0, 17> out by using a conflicting key.
cache.Put(1 << kHashbits, 22);
CHECK(!Has(cache, 0));
CHECK_EQ(MustGet(cache, 1 << kHashbits), 22);
cache.Invalidate(19);
CHECK(!Has(cache, 19));
CHECK(!Has(cache, 0));
CHECK(Has(cache, 1 << kHashbits));
}
int main(int argc, char **argv) {
PackedCacheTest_basic();
printf("PASS\n");
return 0;
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/heap-checker_unittest.sh | .sh | 3,095 | 90 | #!/bin/sh
# Copyright (c) 2005, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ---
# Author: Craig Silverstein
#
# Runs the heap-checker unittest with various environment variables.
# This is necessary because we turn on features like the heap profiler
# and heap checker via environment variables. This test makes sure
# they all play well together.
# We expect BINDIR and PPROF_PATH to be set in the environment.
# If not, we set them to some reasonable values
BINDIR="${BINDIR:-.}"
PPROF_PATH="${PPROF_PATH:-$BINDIR/src/pprof}"
if [ "x$1" = "x-h" -o "$1" = "x--help" ]; then
echo "USAGE: $0 [unittest dir] [path to pprof]"
echo " By default, unittest_dir=$BINDIR, pprof_path=$PPROF_PATH"
exit 1
fi
HEAP_CHECKER="${1:-$BINDIR/heap-checker_unittest}"
PPROF_PATH="${2:-$PPROF_PATH}"
TMPDIR=/tmp/heap_check_info
rm -rf $TMPDIR || exit 2
mkdir $TMPDIR || exit 3
# $1: value of heap-check env. var.
run_check() {
export PPROF_PATH="$PPROF_PATH"
[ -n "$1" ] && export HEAPCHECK="$1" || unset HEAPPROFILE
echo -n "Testing $HEAP_CHECKER with HEAPCHECK=$1 ... "
if $HEAP_CHECKER > $TMPDIR/output 2>&1; then
echo "OK"
else
echo "FAILED"
echo "Output from the failed run:"
echo "----"
cat $TMPDIR/output
echo "----"
exit 4
fi
# If we set HEAPPROFILE, then we expect it to actually have emitted
# a profile. Check that it did.
if [ -n "$HEAPPROFILE" ]; then
[ -e "$HEAPPROFILE.0001.heap" ] || exit 5
fi
}
run_check ""
run_check "local"
run_check "normal"
run_check "strict"
rm -rf $TMPDIR # clean up
echo "PASS"
| Shell |
3D | mcellteam/mcell | libs/gperftools/src/tests/tcmalloc_unittest.cc | .cc | 52,270 | 1,646 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Unittest for the TCMalloc implementation.
//
// * The test consists of a set of threads.
// * Each thread maintains a set of allocated objects, with
// a bound on the total amount of data in the set.
// * Each allocated object's contents are generated by
// hashing the object pointer, and a generation count
// in the object. This allows us to easily check for
// data corruption.
// * At any given step, the thread can do any of the following:
// a. Allocate an object
// b. Increment an object's generation count and update
// its contents.
// c. Pass the object to another thread
// d. Free an object
// Also, at the end of every step, object(s) are freed to maintain
// the memory upper-bound.
//
// If this test is compiled with -DDEBUGALLOCATION, then we don't
// run some tests that test the inner workings of tcmalloc and
// break on debugallocation: that certain allocations are aligned
// in a certain way (even though no standard requires it), and that
// realloc() tries to minimize copying (which debug allocators don't
// care about).
#include "config_for_unittests.h"
// Complicated ordering requirements. tcmalloc.h defines (indirectly)
// _POSIX_C_SOURCE, which it needs so stdlib.h defines posix_memalign.
// unistd.h, on the other hand, requires _POSIX_C_SOURCE to be unset,
// at least on FreeBSD, in order to define sbrk. The solution
// is to #include unistd.h first. This is safe because unistd.h
// doesn't sub-include stdlib.h, so we'll still get posix_memalign
// when we #include stdlib.h. Blah.
#ifdef HAVE_UNISTD_H
#include <unistd.h> // for testing sbrk hooks
#endif
#include "tcmalloc.h" // must come early, to pick up posix_memalign
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef HAVE_STDINT_H
#include <stdint.h> // for intptr_t
#endif
#include <sys/types.h> // for size_t
#ifdef HAVE_FCNTL_H
#include <fcntl.h> // for open; used with mmap-hook test
#endif
#ifdef HAVE_MMAP
#include <sys/mman.h> // for testing mmap hooks
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h> // defines pvalloc/etc on cygwin
#endif
#include <assert.h>
#include <vector>
#include <algorithm>
#include <string>
#include <new>
#include "base/logging.h"
#include "base/simple_mutex.h"
#include "gperftools/malloc_hook.h"
#include "gperftools/malloc_extension.h"
#include "gperftools/nallocx.h"
#include "gperftools/tcmalloc.h"
#include "thread_cache.h"
#include "system-alloc.h"
#include "tests/testutil.h"
// Windows doesn't define pvalloc and a few other obsolete unix
// functions; nor does it define posix_memalign (which is not obsolete).
#if defined(_WIN32)
# define cfree free // don't bother to try to test these obsolete fns
# define valloc malloc
# define pvalloc malloc
// I'd like to map posix_memalign to _aligned_malloc, but _aligned_malloc
// must be paired with _aligned_free (not normal free), which is too
// invasive a change to how we allocate memory here. So just bail
static bool kOSSupportsMemalign = false;
static inline void* Memalign(size_t align, size_t size) {
//LOG(FATAL) << "memalign not supported on windows";
exit(1);
return NULL;
}
static inline int PosixMemalign(void** ptr, size_t align, size_t size) {
//LOG(FATAL) << "posix_memalign not supported on windows";
exit(1);
return -1;
}
// OS X defines posix_memalign in some OS versions but not others;
// it's confusing enough to check that it's easiest to just not to test.
#elif defined(__APPLE__)
static bool kOSSupportsMemalign = false;
static inline void* Memalign(size_t align, size_t size) {
//LOG(FATAL) << "memalign not supported on OS X";
exit(1);
return NULL;
}
static inline int PosixMemalign(void** ptr, size_t align, size_t size) {
//LOG(FATAL) << "posix_memalign not supported on OS X";
exit(1);
return -1;
}
#else
static bool kOSSupportsMemalign = true;
static inline void* Memalign(size_t align, size_t size) {
return memalign(align, size);
}
static inline int PosixMemalign(void** ptr, size_t align, size_t size) {
return posix_memalign(ptr, align, size);
}
#endif
#if defined(ENABLE_ALIGNED_NEW_DELETE)
#define OVERALIGNMENT 64
struct overaligned_type
{
#if defined(__GNUC__)
__attribute__((__aligned__(OVERALIGNMENT)))
#elif defined(_MSC_VER)
__declspec(align(OVERALIGNMENT))
#else
alignas(OVERALIGNMENT)
#endif
unsigned char data[OVERALIGNMENT * 2]; // make the object size different from
// alignment to make sure the correct
// values are passed to the new/delete
// implementation functions
};
#endif // defined(ENABLE_ALIGNED_NEW_DELETE)
// On systems (like freebsd) that don't define MAP_ANONYMOUS, use the old
// form of the name instead.
#ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS MAP_ANON
#endif
#define LOGSTREAM stdout
using std::vector;
using std::string;
DECLARE_double(tcmalloc_release_rate);
DECLARE_int32(max_free_queue_size); // in debugallocation.cc
DECLARE_int64(tcmalloc_sample_parameter);
struct OOMAbleSysAlloc : public SysAllocator {
SysAllocator *child;
int simulate_oom;
void* Alloc(size_t size, size_t* actual_size, size_t alignment) {
if (simulate_oom) {
return NULL;
}
return child->Alloc(size, actual_size, alignment);
}
};
static union {
char buf[sizeof(OOMAbleSysAlloc)];
void *ptr;
} test_sys_alloc_space;
static OOMAbleSysAlloc* get_test_sys_alloc() {
return reinterpret_cast<OOMAbleSysAlloc*>(&test_sys_alloc_space);
}
void setup_oomable_sys_alloc() {
SysAllocator *def = MallocExtension::instance()->GetSystemAllocator();
OOMAbleSysAlloc *alloc = get_test_sys_alloc();
new (alloc) OOMAbleSysAlloc;
alloc->child = def;
MallocExtension::instance()->SetSystemAllocator(alloc);
}
namespace testing {
static const int FLAGS_numtests = 50000;
static const int FLAGS_log_every_n_tests = 50000; // log exactly once
// Testing parameters
static const int FLAGS_lgmaxsize = 16; // lg() of the max size object to alloc
static const int FLAGS_numthreads = 10; // Number of threads
static const int FLAGS_threadmb = 4; // Max memory size allocated by thread
static const int FLAGS_lg_max_memalign = 18; // lg of max alignment for memalign
static const double FLAGS_memalign_min_fraction = 0; // min expected%
static const double FLAGS_memalign_max_fraction = 0.4; // max expected%
static const double FLAGS_memalign_max_alignment_ratio = 6; // alignment/size
// Weights of different operations
static const int FLAGS_allocweight = 50; // Weight for picking allocation
static const int FLAGS_freeweight = 50; // Weight for picking free
static const int FLAGS_updateweight = 10; // Weight for picking update
static const int FLAGS_passweight = 1; // Weight for passing object
static const int kSizeBits = 8 * sizeof(size_t);
static const size_t kMaxSize = ~static_cast<size_t>(0);
static const size_t kMaxSignedSize = ((size_t(1) << (kSizeBits-1)) - 1);
static const size_t kNotTooBig = 100000;
// We want an allocation that is definitely more than main memory. OS
// X has special logic to discard very big allocs before even passing
// the request along to the user-defined memory allocator; we're not
// interested in testing their logic, so we have to make sure we're
// not *too* big.
static const size_t kTooBig = kMaxSize - 100000;
static int news_handled = 0;
// Global array of threads
class TesterThread;
static TesterThread** threads;
// To help with generating random numbers
class TestHarness {
private:
// Information kept per type
struct Type {
string name;
int type;
int weight;
};
public:
TestHarness(int seed)
: types_(new vector<Type>), total_weight_(0), num_tests_(0) {
srandom(seed);
}
~TestHarness() {
delete types_;
}
// Add operation type with specified weight. When starting a new
// iteration, an operation type is picked with probability
// proportional to its weight.
//
// "type" must be non-negative.
// "weight" must be non-negative.
void AddType(int type, int weight, const char* name);
// Call this to get the type of operation for the next iteration.
// It returns a random operation type from the set of registered
// operations. Returns -1 if tests should finish.
int PickType();
// If n == 0, returns the next pseudo-random number in the range [0 .. 0]
// If n != 0, returns the next pseudo-random number in the range [0 .. n)
int Uniform(int n) {
if (n == 0) {
return random() * 0;
} else {
return random() % n;
}
}
// Pick "base" uniformly from range [0,max_log] and then return
// "base" random bits. The effect is to pick a number in the range
// [0,2^max_log-1] with bias towards smaller numbers.
int Skewed(int max_log) {
const int base = random() % (max_log+1);
return random() % (1 << base);
}
private:
vector<Type>* types_; // Registered types
int total_weight_; // Total weight of all types
int num_tests_; // Num tests run so far
};
void TestHarness::AddType(int type, int weight, const char* name) {
Type t;
t.name = name;
t.type = type;
t.weight = weight;
types_->push_back(t);
total_weight_ += weight;
}
int TestHarness::PickType() {
if (num_tests_ >= FLAGS_numtests) return -1;
num_tests_++;
assert(total_weight_ > 0);
// This is a little skewed if total_weight_ doesn't divide 2^31, but it's close
int v = Uniform(total_weight_);
int i;
for (i = 0; i < types_->size(); i++) {
v -= (*types_)[i].weight;
if (v < 0) {
break;
}
}
assert(i < types_->size());
if ((num_tests_ % FLAGS_log_every_n_tests) == 0) {
fprintf(LOGSTREAM, " Test %d out of %d: %s\n",
num_tests_, FLAGS_numtests, (*types_)[i].name.c_str());
}
return (*types_)[i].type;
}
class AllocatorState : public TestHarness {
public:
explicit AllocatorState(int seed) : TestHarness(seed), memalign_fraction_(0) {
if (kOSSupportsMemalign) {
CHECK_GE(FLAGS_memalign_max_fraction, 0);
CHECK_LE(FLAGS_memalign_max_fraction, 1);
CHECK_GE(FLAGS_memalign_min_fraction, 0);
CHECK_LE(FLAGS_memalign_min_fraction, 1);
double delta = FLAGS_memalign_max_fraction - FLAGS_memalign_min_fraction;
CHECK_GE(delta, 0);
memalign_fraction_ = (Uniform(10000)/10000.0 * delta +
FLAGS_memalign_min_fraction);
//fprintf(LOGSTREAM, "memalign fraction: %f\n", memalign_fraction_);
}
}
virtual ~AllocatorState() {}
// Allocate memory. Randomly choose between malloc() or posix_memalign().
void* alloc(size_t size) {
if (Uniform(100) < memalign_fraction_ * 100) {
// Try a few times to find a reasonable alignment, or fall back on malloc.
for (int i = 0; i < 5; i++) {
size_t alignment = 1 << Uniform(FLAGS_lg_max_memalign);
if (alignment >= sizeof(intptr_t) &&
(size < sizeof(intptr_t) ||
alignment < FLAGS_memalign_max_alignment_ratio * size)) {
void *result = reinterpret_cast<void*>(static_cast<intptr_t>(0x1234));
int err = PosixMemalign(&result, alignment, size);
if (err != 0) {
CHECK_EQ(err, ENOMEM);
}
return err == 0 ? result : NULL;
}
}
}
return malloc(size);
}
private:
double memalign_fraction_;
};
// Info kept per thread
class TesterThread {
private:
// Info kept per allocated object
struct Object {
char* ptr; // Allocated pointer
int size; // Allocated size
int generation; // Generation counter of object contents
};
Mutex lock_; // For passing in another thread's obj
int id_; // My thread id
AllocatorState rnd_; // For generating random numbers
vector<Object> heap_; // This thread's heap
vector<Object> passed_; // Pending objects passed from others
size_t heap_size_; // Current heap size
int locks_ok_; // Number of OK TryLock() ops
int locks_failed_; // Number of failed TryLock() ops
// Type of operations
enum Type { ALLOC, FREE, UPDATE, PASS };
// ACM minimal standard random number generator. (re-entrant.)
class ACMRandom {
int32 seed_;
public:
explicit ACMRandom(int32 seed) { seed_ = seed; }
int32 Next() {
const int32 M = 2147483647L; // 2^31-1
const int32 A = 16807;
// In effect, we are computing seed_ = (seed_ * A) % M, where M = 2^31-1
uint32 lo = A * (int32)(seed_ & 0xFFFF);
uint32 hi = A * (int32)((uint32)seed_ >> 16);
lo += (hi & 0x7FFF) << 16;
if (lo > M) {
lo &= M;
++lo;
}
lo += hi >> 15;
if (lo > M) {
lo &= M;
++lo;
}
return (seed_ = (int32) lo);
}
};
public:
TesterThread(int id)
: id_(id),
rnd_(id+1),
heap_size_(0),
locks_ok_(0),
locks_failed_(0) {
}
virtual ~TesterThread() {
if (FLAGS_verbose)
fprintf(LOGSTREAM, "Thread %2d: locks %6d ok; %6d trylocks failed\n",
id_, locks_ok_, locks_failed_);
if (locks_ok_ + locks_failed_ >= 1000) {
CHECK_LE(locks_failed_, locks_ok_ / 2);
}
}
virtual void Run() {
rnd_.AddType(ALLOC, FLAGS_allocweight, "allocate");
rnd_.AddType(FREE, FLAGS_freeweight, "free");
rnd_.AddType(UPDATE, FLAGS_updateweight, "update");
rnd_.AddType(PASS, FLAGS_passweight, "pass");
while (true) {
AcquirePassedObjects();
switch (rnd_.PickType()) {
case ALLOC: AllocateObject(); break;
case FREE: FreeObject(); break;
case UPDATE: UpdateObject(); break;
case PASS: PassObject(); break;
case -1: goto done;
default: assert(NULL == "Unknown type");
}
ShrinkHeap();
}
done:
DeleteHeap();
}
// Allocate a new object
void AllocateObject() {
Object object;
object.size = rnd_.Skewed(FLAGS_lgmaxsize);
object.ptr = static_cast<char*>(rnd_.alloc(object.size));
CHECK(object.ptr);
object.generation = 0;
FillContents(&object);
heap_.push_back(object);
heap_size_ += object.size;
}
// Mutate a random object
void UpdateObject() {
if (heap_.empty()) return;
const int index = rnd_.Uniform(heap_.size());
CheckContents(heap_[index]);
heap_[index].generation++;
FillContents(&heap_[index]);
}
// Free a random object
void FreeObject() {
if (heap_.empty()) return;
const int index = rnd_.Uniform(heap_.size());
Object object = heap_[index];
CheckContents(object);
free(object.ptr);
heap_size_ -= object.size;
heap_[index] = heap_[heap_.size()-1];
heap_.pop_back();
}
// Delete all objects in the heap
void DeleteHeap() {
while (!heap_.empty()) {
FreeObject();
}
}
// Free objects until our heap is small enough
void ShrinkHeap() {
while (heap_size_ > FLAGS_threadmb << 20) {
assert(!heap_.empty());
FreeObject();
}
}
// Pass a random object to another thread
void PassObject() {
// Pick object to pass
if (heap_.empty()) return;
const int index = rnd_.Uniform(heap_.size());
Object object = heap_[index];
CheckContents(object);
// Pick thread to pass
const int tid = rnd_.Uniform(FLAGS_numthreads);
TesterThread* thread = threads[tid];
if (thread->lock_.TryLock()) {
// Pass the object
locks_ok_++;
thread->passed_.push_back(object);
thread->lock_.Unlock();
heap_size_ -= object.size;
heap_[index] = heap_[heap_.size()-1];
heap_.pop_back();
} else {
locks_failed_++;
}
}
// Grab any objects passed to this thread by another thread
void AcquirePassedObjects() {
// We do not create unnecessary contention by always using
// TryLock(). Plus we unlock immediately after swapping passed
// objects into a local vector.
vector<Object> copy;
{ // Locking scope
if (!lock_.TryLock()) {
locks_failed_++;
return;
}
locks_ok_++;
swap(copy, passed_);
lock_.Unlock();
}
for (int i = 0; i < copy.size(); ++i) {
const Object& object = copy[i];
CheckContents(object);
heap_.push_back(object);
heap_size_ += object.size;
}
}
// Fill object contents according to ptr/generation
void FillContents(Object* object) {
ACMRandom r(reinterpret_cast<intptr_t>(object->ptr) & 0x7fffffff);
for (int i = 0; i < object->generation; ++i) {
r.Next();
}
const char c = static_cast<char>(r.Next());
memset(object->ptr, c, object->size);
}
// Check object contents
void CheckContents(const Object& object) {
ACMRandom r(reinterpret_cast<intptr_t>(object.ptr) & 0x7fffffff);
for (int i = 0; i < object.generation; ++i) {
r.Next();
}
// For large objects, we just check a prefix/suffix
const char expected = static_cast<char>(r.Next());
const int limit1 = object.size < 32 ? object.size : 32;
const int start2 = limit1 > object.size - 32 ? limit1 : object.size - 32;
for (int i = 0; i < limit1; ++i) {
CHECK_EQ(object.ptr[i], expected);
}
for (int i = start2; i < object.size; ++i) {
CHECK_EQ(object.ptr[i], expected);
}
}
};
static void RunThread(int thread_id) {
threads[thread_id]->Run();
}
static void TryHugeAllocation(size_t s, AllocatorState* rnd) {
void* p = rnd->alloc(s);
CHECK(p == NULL); // huge allocation s should fail!
}
static void TestHugeAllocations(AllocatorState* rnd) {
// Check that asking for stuff tiny bit smaller than largest possible
// size returns NULL.
for (size_t i = 0; i < 70000; i += rnd->Uniform(20)) {
TryHugeAllocation(kMaxSize - i, rnd);
}
// Asking for memory sizes near signed/unsigned boundary (kMaxSignedSize)
// might work or not, depending on the amount of virtual memory.
#ifndef DEBUGALLOCATION // debug allocation takes forever for huge allocs
for (size_t i = 0; i < 100; i++) {
void* p = NULL;
p = rnd->alloc(kMaxSignedSize + i);
if (p) free(p); // if: free(NULL) is not necessarily defined
p = rnd->alloc(kMaxSignedSize - i);
if (p) free(p);
}
#endif
// Check that ReleaseFreeMemory has no visible effect (aka, does not
// crash the test):
MallocExtension* inst = MallocExtension::instance();
CHECK(inst);
inst->ReleaseFreeMemory();
}
static void TestCalloc(size_t n, size_t s, bool ok) {
char* p = reinterpret_cast<char*>(calloc(n, s));
if (FLAGS_verbose)
fprintf(LOGSTREAM, "calloc(%" PRIxS ", %" PRIxS "): %p\n", n, s, p);
if (!ok) {
CHECK(p == NULL); // calloc(n, s) should not succeed
} else {
CHECK(p != NULL); // calloc(n, s) should succeed
for (int i = 0; i < n*s; i++) {
CHECK(p[i] == '\0');
}
free(p);
}
}
// This makes sure that reallocing a small number of bytes in either
// direction doesn't cause us to allocate new memory.
static void TestRealloc() {
#ifndef DEBUGALLOCATION // debug alloc doesn't try to minimize reallocs
// When sampling, we always allocate in units of page-size, which
// makes reallocs of small sizes do extra work (thus, failing these
// checks). Since sampling is random, we turn off sampling to make
// sure that doesn't happen to us here.
const int64 old_sample_parameter = FLAGS_tcmalloc_sample_parameter;
FLAGS_tcmalloc_sample_parameter = 0; // turn off sampling
int start_sizes[] = { 100, 1000, 10000, 100000 };
int deltas[] = { 1, -2, 4, -8, 16, -32, 64, -128 };
for (int s = 0; s < sizeof(start_sizes)/sizeof(*start_sizes); ++s) {
void* p = malloc(start_sizes[s]);
CHECK(p);
// The larger the start-size, the larger the non-reallocing delta.
for (int d = 0; d < (s+1) * 2; ++d) {
void* new_p = realloc(p, start_sizes[s] + deltas[d]);
CHECK(p == new_p); // realloc should not allocate new memory
}
// Test again, but this time reallocing smaller first.
for (int d = 0; d < s*2; ++d) {
void* new_p = realloc(p, start_sizes[s] - deltas[d]);
CHECK(p == new_p); // realloc should not allocate new memory
}
free(p);
}
FLAGS_tcmalloc_sample_parameter = old_sample_parameter;
#endif
}
static void TestNewHandler() {
++news_handled;
throw std::bad_alloc();
}
static void TestOneNew(void* (*func)(size_t)) {
// success test
try {
void* ptr = (*func)(kNotTooBig);
if (0 == ptr) {
fprintf(LOGSTREAM, "allocation should not have failed.\n");
abort();
}
} catch (...) {
fprintf(LOGSTREAM, "allocation threw unexpected exception.\n");
abort();
}
// failure test
// we should always receive a bad_alloc exception
try {
(*func)(kTooBig);
fprintf(LOGSTREAM, "allocation should have failed.\n");
abort();
} catch (const std::bad_alloc&) {
// correct
} catch (...) {
fprintf(LOGSTREAM, "allocation threw unexpected exception.\n");
abort();
}
}
static void TestNew(void* (*func)(size_t)) {
news_handled = 0;
// test without new_handler:
std::new_handler saved_handler = std::set_new_handler(0);
TestOneNew(func);
// test with new_handler:
std::set_new_handler(TestNewHandler);
TestOneNew(func);
if (news_handled != 1) {
fprintf(LOGSTREAM, "new_handler was not called.\n");
abort();
}
std::set_new_handler(saved_handler);
}
static void TestOneNothrowNew(void* (*func)(size_t, const std::nothrow_t&)) {
// success test
try {
void* ptr = (*func)(kNotTooBig, std::nothrow);
if (0 == ptr) {
fprintf(LOGSTREAM, "allocation should not have failed.\n");
abort();
}
} catch (...) {
fprintf(LOGSTREAM, "allocation threw unexpected exception.\n");
abort();
}
// failure test
// we should always receive a bad_alloc exception
try {
if ((*func)(kTooBig, std::nothrow) != 0) {
fprintf(LOGSTREAM, "allocation should have failed.\n");
abort();
}
} catch (...) {
fprintf(LOGSTREAM, "nothrow allocation threw unexpected exception.\n");
abort();
}
}
static void TestNothrowNew(void* (*func)(size_t, const std::nothrow_t&)) {
news_handled = 0;
// test without new_handler:
std::new_handler saved_handler = std::set_new_handler(0);
TestOneNothrowNew(func);
// test with new_handler:
std::set_new_handler(TestNewHandler);
TestOneNothrowNew(func);
if (news_handled != 1) {
fprintf(LOGSTREAM, "nothrow new_handler was not called.\n");
abort();
}
std::set_new_handler(saved_handler);
}
// These are used as callbacks by the sanity-check. Set* and Reset*
// register the hook that counts how many times the associated memory
// function is called. After each such call, call Verify* to verify
// that we used the tcmalloc version of the call, and not the libc.
// Note the ... in the hook signature: we don't care what arguments
// the hook takes.
#define MAKE_HOOK_CALLBACK(hook_type, ...) \
static volatile int g_##hook_type##_calls = 0; \
static void IncrementCallsTo##hook_type(__VA_ARGS__) { \
g_##hook_type##_calls++; \
} \
static void Verify##hook_type##WasCalled() { \
CHECK_GT(g_##hook_type##_calls, 0); \
g_##hook_type##_calls = 0; /* reset for next call */ \
} \
static void Set##hook_type() { \
CHECK(MallocHook::Add##hook_type( \
(MallocHook::hook_type)&IncrementCallsTo##hook_type)); \
} \
static void Reset##hook_type() { \
CHECK(MallocHook::Remove##hook_type( \
(MallocHook::hook_type)&IncrementCallsTo##hook_type)); \
}
// We do one for each hook typedef in malloc_hook.h
MAKE_HOOK_CALLBACK(NewHook, const void*, size_t);
MAKE_HOOK_CALLBACK(DeleteHook, const void*);
MAKE_HOOK_CALLBACK(MmapHook, const void*, const void*, size_t, int, int, int,
off_t);
MAKE_HOOK_CALLBACK(MremapHook, const void*, const void*, size_t, size_t, int,
const void*);
MAKE_HOOK_CALLBACK(MunmapHook, const void *, size_t);
MAKE_HOOK_CALLBACK(SbrkHook, const void *, ptrdiff_t);
static void TestAlignmentForSize(int size) {
fprintf(LOGSTREAM, "Testing alignment of malloc(%d)\n", size);
static const int kNum = 100;
void* ptrs[kNum];
for (int i = 0; i < kNum; i++) {
ptrs[i] = malloc(size);
uintptr_t p = reinterpret_cast<uintptr_t>(ptrs[i]);
CHECK((p % sizeof(void*)) == 0);
CHECK((p % sizeof(double)) == 0);
// Must have 16-byte (or 8-byte in case of -DTCMALLOC_ALIGN_8BYTES)
// alignment for large enough objects
if (size >= kMinAlign) {
CHECK((p % kMinAlign) == 0);
}
}
for (int i = 0; i < kNum; i++) {
free(ptrs[i]);
}
}
static void TestMallocAlignment() {
for (int lg = 0; lg < 16; lg++) {
TestAlignmentForSize((1<<lg) - 1);
TestAlignmentForSize((1<<lg) + 0);
TestAlignmentForSize((1<<lg) + 1);
}
}
static void TestHugeThreadCache() {
fprintf(LOGSTREAM, "==== Testing huge thread cache\n");
// More than 2^16 to cause integer overflow of 16 bit counters.
static const int kNum = 70000;
char** array = new char*[kNum];
for (int i = 0; i < kNum; ++i) {
array[i] = new char[10];
}
for (int i = 0; i < kNum; ++i) {
delete[] array[i];
}
delete[] array;
}
namespace {
struct RangeCallbackState {
uintptr_t ptr;
base::MallocRange::Type expected_type;
size_t min_size;
bool matched;
};
static void RangeCallback(void* arg, const base::MallocRange* r) {
RangeCallbackState* state = reinterpret_cast<RangeCallbackState*>(arg);
if (state->ptr >= r->address &&
state->ptr < r->address + r->length) {
if (state->expected_type == base::MallocRange::FREE) {
// We are expecting r->type == FREE, but ReleaseMemory
// may have already moved us to UNMAPPED state instead (this happens in
// approximately 0.1% of executions). Accept either state.
CHECK(r->type == base::MallocRange::FREE ||
r->type == base::MallocRange::UNMAPPED);
} else {
CHECK_EQ(r->type, state->expected_type);
}
CHECK_GE(r->length, state->min_size);
state->matched = true;
}
}
// Check that at least one of the callbacks from Ranges() contains
// the specified address with the specified type, and has size
// >= min_size.
static void CheckRangeCallback(void* ptr, base::MallocRange::Type type,
size_t min_size) {
RangeCallbackState state;
state.ptr = reinterpret_cast<uintptr_t>(ptr);
state.expected_type = type;
state.min_size = min_size;
state.matched = false;
MallocExtension::instance()->Ranges(&state, RangeCallback);
CHECK(state.matched);
}
}
static bool HaveSystemRelease =
TCMalloc_SystemRelease(TCMalloc_SystemAlloc(kPageSize, NULL, 0), kPageSize);
static void TestRanges() {
static const int MB = 1048576;
void* a = malloc(MB);
void* b = malloc(MB);
base::MallocRange::Type releasedType =
HaveSystemRelease ? base::MallocRange::UNMAPPED : base::MallocRange::FREE;
CheckRangeCallback(a, base::MallocRange::INUSE, MB);
CheckRangeCallback(b, base::MallocRange::INUSE, MB);
free(a);
CheckRangeCallback(a, base::MallocRange::FREE, MB);
CheckRangeCallback(b, base::MallocRange::INUSE, MB);
MallocExtension::instance()->ReleaseFreeMemory();
CheckRangeCallback(a, releasedType, MB);
CheckRangeCallback(b, base::MallocRange::INUSE, MB);
free(b);
CheckRangeCallback(a, releasedType, MB);
CheckRangeCallback(b, base::MallocRange::FREE, MB);
}
#ifndef DEBUGALLOCATION
static size_t GetUnmappedBytes() {
size_t bytes;
CHECK(MallocExtension::instance()->GetNumericProperty(
"tcmalloc.pageheap_unmapped_bytes", &bytes));
return bytes;
}
#endif
class AggressiveDecommitChanger {
size_t old_value_;
public:
AggressiveDecommitChanger(size_t new_value) {
MallocExtension *inst = MallocExtension::instance();
bool rv = inst->GetNumericProperty("tcmalloc.aggressive_memory_decommit", &old_value_);
CHECK_CONDITION(rv);
rv = inst->SetNumericProperty("tcmalloc.aggressive_memory_decommit", new_value);
CHECK_CONDITION(rv);
}
~AggressiveDecommitChanger() {
MallocExtension *inst = MallocExtension::instance();
bool rv = inst->SetNumericProperty("tcmalloc.aggressive_memory_decommit", old_value_);
CHECK_CONDITION(rv);
}
};
static void TestReleaseToSystem() {
// Debug allocation mode adds overhead to each allocation which
// messes up all the equality tests here. I just disable the
// teset in this mode. TODO(csilvers): get it to work for debugalloc?
#ifndef DEBUGALLOCATION
if(!HaveSystemRelease) return;
const double old_tcmalloc_release_rate = FLAGS_tcmalloc_release_rate;
FLAGS_tcmalloc_release_rate = 0;
AggressiveDecommitChanger disabler(0);
static const int MB = 1048576;
void* a = malloc(MB);
void* b = malloc(MB);
MallocExtension::instance()->ReleaseFreeMemory();
size_t starting_bytes = GetUnmappedBytes();
// Calling ReleaseFreeMemory() a second time shouldn't do anything.
MallocExtension::instance()->ReleaseFreeMemory();
EXPECT_EQ(starting_bytes, GetUnmappedBytes());
// ReleaseToSystem shouldn't do anything either.
MallocExtension::instance()->ReleaseToSystem(MB);
EXPECT_EQ(starting_bytes, GetUnmappedBytes());
free(a);
// The span to release should be 1MB.
MallocExtension::instance()->ReleaseToSystem(MB/2);
EXPECT_EQ(starting_bytes + MB, GetUnmappedBytes());
// Should do nothing since the previous call released too much.
MallocExtension::instance()->ReleaseToSystem(MB/4);
EXPECT_EQ(starting_bytes + MB, GetUnmappedBytes());
free(b);
// Use up the extra MB/4 bytes from 'a' and also release 'b'.
MallocExtension::instance()->ReleaseToSystem(MB/2);
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
// Should do nothing since the previous call released too much.
MallocExtension::instance()->ReleaseToSystem(MB/2);
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
// Nothing else to release.
MallocExtension::instance()->ReleaseFreeMemory();
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
a = malloc(MB);
free(a);
EXPECT_EQ(starting_bytes + MB, GetUnmappedBytes());
// Releasing less than a page should still trigger a release.
MallocExtension::instance()->ReleaseToSystem(1);
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
FLAGS_tcmalloc_release_rate = old_tcmalloc_release_rate;
#endif // #ifndef DEBUGALLOCATION
}
static void TestAggressiveDecommit() {
// Debug allocation mode adds overhead to each allocation which
// messes up all the equality tests here. I just disable the
// teset in this mode.
#ifndef DEBUGALLOCATION
if(!HaveSystemRelease) return;
fprintf(LOGSTREAM, "Testing aggressive de-commit\n");
AggressiveDecommitChanger enabler(1);
static const int MB = 1048576;
void* a = malloc(MB);
void* b = malloc(MB);
size_t starting_bytes = GetUnmappedBytes();
// ReleaseToSystem shouldn't do anything either.
MallocExtension::instance()->ReleaseToSystem(MB);
EXPECT_EQ(starting_bytes, GetUnmappedBytes());
free(a);
// The span to release should be 1MB.
EXPECT_EQ(starting_bytes + MB, GetUnmappedBytes());
free(b);
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
// Nothing else to release.
MallocExtension::instance()->ReleaseFreeMemory();
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
a = malloc(MB);
free(a);
EXPECT_EQ(starting_bytes + 2*MB, GetUnmappedBytes());
fprintf(LOGSTREAM, "Done testing aggressive de-commit\n");
#endif // #ifndef DEBUGALLOCATION
}
// On MSVC10, in release mode, the optimizer convinces itself
// g_no_memory is never changed (I guess it doesn't realize OnNoMemory
// might be called). Work around this by setting the var volatile.
volatile bool g_no_memory = false;
std::new_handler g_old_handler = NULL;
static void OnNoMemory() {
g_no_memory = true;
std::set_new_handler(g_old_handler);
}
static void TestSetNewMode() {
int old_mode = tc_set_new_mode(1);
g_old_handler = std::set_new_handler(&OnNoMemory);
g_no_memory = false;
void* ret = malloc(kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_TRUE(g_no_memory);
g_old_handler = std::set_new_handler(&OnNoMemory);
g_no_memory = false;
ret = calloc(1, kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_TRUE(g_no_memory);
g_old_handler = std::set_new_handler(&OnNoMemory);
g_no_memory = false;
ret = realloc(NULL, kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_TRUE(g_no_memory);
if (kOSSupportsMemalign) {
// Not really important, but must be small enough such that
// kAlignment + kTooBig does not overflow.
const int kAlignment = 1 << 5;
g_old_handler = std::set_new_handler(&OnNoMemory);
g_no_memory = false;
ret = Memalign(kAlignment, kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_TRUE(g_no_memory);
g_old_handler = std::set_new_handler(&OnNoMemory);
g_no_memory = false;
EXPECT_EQ(ENOMEM,
PosixMemalign(&ret, kAlignment, kTooBig));
EXPECT_EQ(NULL, ret);
EXPECT_TRUE(g_no_memory);
}
tc_set_new_mode(old_mode);
}
static void TestErrno(void) {
void* ret;
if (kOSSupportsMemalign) {
errno = 0;
ret = Memalign(128, kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_EQ(ENOMEM, errno);
}
errno = 0;
ret = malloc(kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_EQ(ENOMEM, errno);
errno = 0;
ret = tc_malloc_skip_new_handler(kTooBig);
EXPECT_EQ(NULL, ret);
EXPECT_EQ(ENOMEM, errno);
}
#ifndef DEBUGALLOCATION
// Ensure that nallocx works before main.
struct GlobalNallocx {
GlobalNallocx() { CHECK_GT(nallocx(99, 0), 99); }
} global_nallocx;
#if defined(__GNUC__)
static void check_global_nallocx() __attribute__((constructor));
static void check_global_nallocx() { CHECK_GT(nallocx(99, 0), 99); }
#endif // __GNUC__
static void TestNAllocX() {
for (size_t size = 0; size <= (1 << 20); size += 7) {
size_t rounded = nallocx(size, 0);
ASSERT_GE(rounded, size);
void* ptr = malloc(size);
ASSERT_EQ(rounded, MallocExtension::instance()->GetAllocatedSize(ptr));
free(ptr);
}
}
static void TestNAllocXAlignment() {
for (size_t size = 0; size <= (1 << 20); size += 7) {
for (size_t align = 0; align < 10; align++) {
size_t rounded = nallocx(size, MALLOCX_LG_ALIGN(align));
ASSERT_GE(rounded, size);
ASSERT_EQ(rounded % (1 << align), 0);
void* ptr = tc_memalign(1 << align, size);
ASSERT_EQ(rounded, MallocExtension::instance()->GetAllocatedSize(ptr));
free(ptr);
}
}
}
static int saw_new_handler_runs;
static void* volatile oom_test_last_ptr;
static void test_new_handler() {
get_test_sys_alloc()->simulate_oom = false;
void *ptr = oom_test_last_ptr;
oom_test_last_ptr = NULL;
::operator delete[](ptr);
saw_new_handler_runs++;
}
static ATTRIBUTE_NOINLINE void TestNewOOMHandling() {
// debug allocator does internal allocations and crashes when such
// internal allocation fails. So don't test it.
setup_oomable_sys_alloc();
std::new_handler old = std::set_new_handler(test_new_handler);
get_test_sys_alloc()->simulate_oom = true;
ASSERT_EQ(saw_new_handler_runs, 0);
for (int i = 0; i < 10240; i++) {
oom_test_last_ptr = new char [512];
ASSERT_NE(oom_test_last_ptr, NULL);
if (saw_new_handler_runs) {
break;
}
}
ASSERT_GE(saw_new_handler_runs, 1);
get_test_sys_alloc()->simulate_oom = false;
std::set_new_handler(old);
}
#endif // !DEBUGALLOCATION
static int RunAllTests(int argc, char** argv) {
// Optional argv[1] is the seed
AllocatorState rnd(argc > 1 ? atoi(argv[1]) : 100);
SetTestResourceLimit();
#ifndef DEBUGALLOCATION
TestNewOOMHandling();
#endif
// TODO(odo): This test has been disabled because it is only by luck that it
// does not result in fragmentation. When tcmalloc makes an allocation which
// spans previously unused leaves of the pagemap it will allocate and fill in
// the leaves to cover the new allocation. The leaves happen to be 256MiB in
// the 64-bit build, and with the sbrk allocator these allocations just
// happen to fit in one leaf by luck. With other allocators (mmap,
// memfs_malloc when used with small pages) the allocations generally span
// two leaves and this results in a very bad fragmentation pattern with this
// code. The same failure can be forced with the sbrk allocator just by
// allocating something on the order of 128MiB prior to starting this test so
// that the test allocations straddle a 256MiB boundary.
// TODO(csilvers): port MemoryUsage() over so the test can use that
#if 0
# include <unistd.h> // for getpid()
// Allocate and deallocate blocks of increasing sizes to check if the alloc
// metadata fragments the memory. (Do not put other allocations/deallocations
// before this test, it may break).
{
size_t memory_usage = MemoryUsage(getpid());
fprintf(LOGSTREAM, "Testing fragmentation\n");
for ( int i = 200; i < 240; ++i ) {
int size = i << 20;
void *test1 = rnd.alloc(size);
CHECK(test1);
for ( int j = 0; j < size; j += (1 << 12) ) {
static_cast<char*>(test1)[j] = 1;
}
free(test1);
}
// There may still be a bit of fragmentation at the beginning, until we
// reach kPageMapBigAllocationThreshold bytes so we check for
// 200 + 240 + margin.
CHECK_LT(MemoryUsage(getpid()), memory_usage + (450 << 20) );
}
#endif
// Check that empty allocation works
fprintf(LOGSTREAM, "Testing empty allocation\n");
{
void* p1 = rnd.alloc(0);
CHECK(p1 != NULL);
void* p2 = rnd.alloc(0);
CHECK(p2 != NULL);
CHECK(p1 != p2);
free(p1);
free(p2);
}
// This code stresses some of the memory allocation via STL.
// It may call operator delete(void*, nothrow_t).
fprintf(LOGSTREAM, "Testing STL use\n");
{
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(0);
std::stable_sort(v.begin(), v.end());
}
// Test each of the memory-allocation functions once, just as a sanity-check
fprintf(LOGSTREAM, "Sanity-testing all the memory allocation functions\n");
{
// We use new-hook and delete-hook to verify we actually called the
// tcmalloc version of these routines, and not the libc version.
SetNewHook(); // defined as part of MAKE_HOOK_CALLBACK, above
SetDeleteHook(); // ditto
void* p1 = malloc(10);
CHECK(p1 != NULL); // force use of this variable
VerifyNewHookWasCalled();
// Also test the non-standard tc_malloc_size
size_t actual_p1_size = tc_malloc_size(p1);
CHECK_GE(actual_p1_size, 10);
CHECK_LT(actual_p1_size, 100000); // a reasonable upper-bound, I think
free(p1);
VerifyDeleteHookWasCalled();
p1 = tc_malloc_skip_new_handler(10);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
free(p1);
VerifyDeleteHookWasCalled();
p1 = calloc(10, 2);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
// We make sure we realloc to a big size, since some systems (OS
// X) will notice if the realloced size continues to fit into the
// malloc-block and make this a noop if so.
p1 = realloc(p1, 30000);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
VerifyDeleteHookWasCalled();
cfree(p1); // synonym for free
VerifyDeleteHookWasCalled();
if (kOSSupportsMemalign) {
CHECK_EQ(PosixMemalign(&p1, sizeof(p1), 40), 0);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
free(p1);
VerifyDeleteHookWasCalled();
p1 = Memalign(sizeof(p1) * 2, 50);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
free(p1);
VerifyDeleteHookWasCalled();
}
// Windows has _aligned_malloc. Let's test that that's captured too.
#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(PERFTOOLS_NO_ALIGNED_MALLOC)
p1 = _aligned_malloc(sizeof(p1) * 2, 64);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
_aligned_free(p1);
VerifyDeleteHookWasCalled();
#endif
p1 = valloc(60);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
free(p1);
VerifyDeleteHookWasCalled();
p1 = pvalloc(70);
CHECK(p1 != NULL);
VerifyNewHookWasCalled();
free(p1);
VerifyDeleteHookWasCalled();
char* p2 = new char;
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
delete p2;
VerifyDeleteHookWasCalled();
p2 = new char[100];
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
delete[] p2;
VerifyDeleteHookWasCalled();
p2 = new(std::nothrow) char;
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
delete p2;
VerifyDeleteHookWasCalled();
p2 = new(std::nothrow) char[100];
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
delete[] p2;
VerifyDeleteHookWasCalled();
// Another way of calling operator new
p2 = static_cast<char*>(::operator new(100));
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
::operator delete(p2);
VerifyDeleteHookWasCalled();
// Try to call nothrow's delete too. Compilers use this.
p2 = static_cast<char*>(::operator new(100, std::nothrow));
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
::operator delete(p2, std::nothrow);
VerifyDeleteHookWasCalled();
#ifdef ENABLE_SIZED_DELETE
p2 = new char;
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
::operator delete(p2, sizeof(char));
VerifyDeleteHookWasCalled();
p2 = new char[100];
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
::operator delete[](p2, sizeof(char) * 100);
VerifyDeleteHookWasCalled();
#endif
#if defined(ENABLE_ALIGNED_NEW_DELETE)
overaligned_type* poveraligned = new overaligned_type;
CHECK(poveraligned != NULL);
CHECK((((size_t)poveraligned) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
delete poveraligned;
VerifyDeleteHookWasCalled();
poveraligned = new overaligned_type[10];
CHECK(poveraligned != NULL);
CHECK((((size_t)poveraligned) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
delete[] poveraligned;
VerifyDeleteHookWasCalled();
poveraligned = new(std::nothrow) overaligned_type;
CHECK(poveraligned != NULL);
CHECK((((size_t)poveraligned) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
delete poveraligned;
VerifyDeleteHookWasCalled();
poveraligned = new(std::nothrow) overaligned_type[10];
CHECK(poveraligned != NULL);
CHECK((((size_t)poveraligned) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
delete[] poveraligned;
VerifyDeleteHookWasCalled();
// Another way of calling operator new
p2 = static_cast<char*>(::operator new(100, std::align_val_t(OVERALIGNMENT)));
CHECK(p2 != NULL);
CHECK((((size_t)p2) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
::operator delete(p2, std::align_val_t(OVERALIGNMENT));
VerifyDeleteHookWasCalled();
p2 = static_cast<char*>(::operator new(100, std::align_val_t(OVERALIGNMENT), std::nothrow));
CHECK(p2 != NULL);
CHECK((((size_t)p2) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
::operator delete(p2, std::align_val_t(OVERALIGNMENT), std::nothrow);
VerifyDeleteHookWasCalled();
#ifdef ENABLE_SIZED_DELETE
poveraligned = new overaligned_type;
CHECK(poveraligned != NULL);
CHECK((((size_t)poveraligned) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
::operator delete(poveraligned, sizeof(overaligned_type), std::align_val_t(OVERALIGNMENT));
VerifyDeleteHookWasCalled();
poveraligned = new overaligned_type[10];
CHECK(poveraligned != NULL);
CHECK((((size_t)poveraligned) % OVERALIGNMENT) == 0u);
VerifyNewHookWasCalled();
::operator delete[](poveraligned, sizeof(overaligned_type) * 10, std::align_val_t(OVERALIGNMENT));
VerifyDeleteHookWasCalled();
#endif
#endif // defined(ENABLE_ALIGNED_NEW_DELETE)
// Try strdup(), which the system allocates but we must free. If
// all goes well, libc will use our malloc!
p2 = strdup("in memory of James Golick");
CHECK(p2 != NULL);
VerifyNewHookWasCalled();
free(p2);
VerifyDeleteHookWasCalled();
// Test mmap too: both anonymous mmap and mmap of a file
// Note that for right now we only override mmap on linux
// systems, so those are the only ones for which we check.
SetMmapHook();
SetMremapHook();
SetMunmapHook();
#if defined(HAVE_MMAP) && defined(__linux) && \
(defined(__i386__) || defined(__x86_64__))
int size = 8192*2;
p1 = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
CHECK(p1 != NULL);
VerifyMmapHookWasCalled();
p1 = mremap(p1, size, size/2, 0);
CHECK(p1 != NULL);
VerifyMremapHookWasCalled();
size /= 2;
munmap(p1, size);
VerifyMunmapHookWasCalled();
int fd = open("/dev/zero", O_RDONLY);
CHECK_GE(fd, 0); // make sure the open succeeded
p1 = mmap(NULL, 8192, PROT_READ, MAP_SHARED, fd, 0);
CHECK(p1 != NULL);
VerifyMmapHookWasCalled();
munmap(p1, 8192);
VerifyMunmapHookWasCalled();
close(fd);
#else // this is just to quiet the compiler: make sure all fns are called
IncrementCallsToMmapHook(NULL, NULL, 0, 0, 0, 0, 0);
IncrementCallsToMunmapHook(NULL, 0);
IncrementCallsToMremapHook(NULL, NULL, 0, 0, 0, NULL);
VerifyMmapHookWasCalled();
VerifyMremapHookWasCalled();
VerifyMunmapHookWasCalled();
#endif
// Test sbrk
SetSbrkHook();
#if defined(HAVE_SBRK) && defined(__linux) && \
(defined(__i386__) || defined(__x86_64__))
p1 = sbrk(8192);
CHECK(p1 != NULL);
VerifySbrkHookWasCalled();
p1 = sbrk(-8192);
CHECK(p1 != NULL);
VerifySbrkHookWasCalled();
// However, sbrk hook should *not* be called with sbrk(0)
p1 = sbrk(0);
CHECK(p1 != NULL);
CHECK_EQ(g_SbrkHook_calls, 0);
#else // this is just to quiet the compiler: make sure all fns are called
IncrementCallsToSbrkHook(NULL, 0);
VerifySbrkHookWasCalled();
#endif
// Reset the hooks to what they used to be. These are all
// defined as part of MAKE_HOOK_CALLBACK, above.
ResetNewHook();
ResetDeleteHook();
ResetMmapHook();
ResetMremapHook();
ResetMunmapHook();
ResetSbrkHook();
}
// Check that "lots" of memory can be allocated
fprintf(LOGSTREAM, "Testing large allocation\n");
{
const int mb_to_allocate = 100;
void* p = rnd.alloc(mb_to_allocate << 20);
CHECK(p != NULL); // could not allocate
free(p);
}
TestMallocAlignment();
// Check calloc() with various arguments
fprintf(LOGSTREAM, "Testing calloc\n");
TestCalloc(0, 0, true);
TestCalloc(0, 1, true);
TestCalloc(1, 1, true);
TestCalloc(1<<10, 0, true);
TestCalloc(1<<20, 0, true);
TestCalloc(0, 1<<10, true);
TestCalloc(0, 1<<20, true);
TestCalloc(1<<20, 2, true);
TestCalloc(2, 1<<20, true);
TestCalloc(1000, 1000, true);
TestCalloc(kMaxSize, 2, false);
TestCalloc(2, kMaxSize, false);
TestCalloc(kMaxSize, kMaxSize, false);
TestCalloc(kMaxSignedSize, 3, false);
TestCalloc(3, kMaxSignedSize, false);
TestCalloc(kMaxSignedSize, kMaxSignedSize, false);
// Test that realloc doesn't always reallocate and copy memory.
fprintf(LOGSTREAM, "Testing realloc\n");
TestRealloc();
fprintf(LOGSTREAM, "Testing operator new(nothrow).\n");
TestNothrowNew(&::operator new);
fprintf(LOGSTREAM, "Testing operator new[](nothrow).\n");
TestNothrowNew(&::operator new[]);
fprintf(LOGSTREAM, "Testing operator new.\n");
TestNew(&::operator new);
fprintf(LOGSTREAM, "Testing operator new[].\n");
TestNew(&::operator new[]);
// Create threads
fprintf(LOGSTREAM, "Testing threaded allocation/deallocation (%d threads)\n",
FLAGS_numthreads);
threads = new TesterThread*[FLAGS_numthreads];
for (int i = 0; i < FLAGS_numthreads; ++i) {
threads[i] = new TesterThread(i);
}
// This runs all the tests at the same time, with a 1M stack size each
RunManyThreadsWithId(RunThread, FLAGS_numthreads, 1<<20);
for (int i = 0; i < FLAGS_numthreads; ++i) delete threads[i]; // Cleanup
// Do the memory intensive tests after threads are done, since exhausting
// the available address space can make pthread_create to fail.
// Check that huge allocations fail with NULL instead of crashing
fprintf(LOGSTREAM, "Testing huge allocations\n");
TestHugeAllocations(&rnd);
// Check that large allocations fail with NULL instead of crashing
#ifndef DEBUGALLOCATION // debug allocation takes forever for huge allocs
fprintf(LOGSTREAM, "Testing out of memory\n");
for (int s = 0; ; s += (10<<20)) {
void* large_object = rnd.alloc(s);
if (large_object == NULL) break;
free(large_object);
}
#endif
TestHugeThreadCache();
TestRanges();
TestReleaseToSystem();
TestAggressiveDecommit();
TestSetNewMode();
TestErrno();
// GetAllocatedSize under DEBUGALLOCATION returns the size that we asked for.
#ifndef DEBUGALLOCATION
TestNAllocX();
TestNAllocXAlignment();
#endif
return 0;
}
}
using testing::RunAllTests;
int main(int argc, char** argv) {
#ifdef DEBUGALLOCATION // debug allocation takes forever for huge allocs
FLAGS_max_free_queue_size = 0; // return freed blocks to tcmalloc immediately
#endif
RunAllTests(argc, argv);
// Test tc_version()
fprintf(LOGSTREAM, "Testing tc_version()\n");
int major;
int minor;
const char* patch;
char mmp[64];
const char* human_version = tc_version(&major, &minor, &patch);
snprintf(mmp, sizeof(mmp), "%d.%d%s", major, minor, patch);
CHECK(!strcmp(PACKAGE_STRING, human_version));
CHECK(!strcmp(PACKAGE_VERSION, mmp));
fprintf(LOGSTREAM, "PASS\n");
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/profiler_unittest.sh | .sh | 10,801 | 270 | #!/bin/sh
# Copyright (c) 2005, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ---
# Author: Craig Silverstein
#
# Runs the 4 profiler unittests and makes sure their profiles look
# appropriate. We expect two commandline args, as described below.
#
# We run under the assumption that if $PROFILER1 is run with no
# arguments, it prints a usage line of the form
# USAGE: <actual executable being run> [...]
#
# This is because libtool sometimes turns the 'executable' into a
# shell script which runs an actual binary somewhere else.
# We expect BINDIR and PPROF_PATH to be set in the environment.
# If not, we set them to some reasonable values
BINDIR="${BINDIR:-.}"
PPROF_PATH="${PPROF_PATH:-$BINDIR/src/pprof}"
if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then
echo "USAGE: $0 [unittest dir] [path to pprof]"
echo " By default, unittest_dir=$BINDIR, pprof_path=$PPROF_PATH"
exit 1
fi
TMPDIR=/tmp/profile_info
UNITTEST_DIR=${1:-$BINDIR}
PPROF=${2:-$PPROF_PATH}
# We test the sliding-window functionality of the cpu-profile reader
# by using a small stride, forcing lots of reads.
PPROF_FLAGS="--test_stride=128"
PROFILER1="$UNITTEST_DIR/profiler1_unittest"
PROFILER2="$UNITTEST_DIR/profiler2_unittest"
PROFILER3="$UNITTEST_DIR/profiler3_unittest"
PROFILER4="$UNITTEST_DIR/profiler4_unittest"
# Unfortunately, for us, libtool can replace executables with a shell
# script that does some work before calling the 'real' executable
# under a different name. We need the 'real' executable name to run
# pprof on it. We've constructed all the binaries used in this
# unittest so when they are called with no arguments, they report
# their argv[0], which is the real binary name.
Realname() {
"$1" 2>&1 | awk '{print $2; exit;}'
}
PROFILER1_REALNAME=`Realname "$PROFILER1"`
PROFILER2_REALNAME=`Realname "$PROFILER2"`
PROFILER3_REALNAME=`Realname "$PROFILER3"`
PROFILER4_REALNAME=`Realname "$PROFILER4"`
# It's meaningful to the profiler, so make sure we know its state
unset CPUPROFILE
# Some output/logging in the profiler can cause issues when running the unit
# tests. For example, logging a warning when the profiler is detected as being
# present but no CPUPROFILE is specified in the environment. Especially when
# we are checking for a silent run or specific timing constraints are being
# checked. So set the env variable signifying that we are running in a unit
# test environment.
PERFTOOLS_UNITTEST=1
rm -rf "$TMPDIR"
mkdir "$TMPDIR" || exit 2
num_failures=0
RegisterFailure() {
num_failures=`expr $num_failures + 1`
}
# Takes two filenames representing profiles, with their executable scripts,
# and a multiplier, and verifies that the 'contentful' functions in each
# profile take the same time (possibly scaled by the given multiplier). It
# used to be "same" meant within 50%, after adding an noise-reducing X units
# to each value. But even that would often spuriously fail, so now it's
# "both non-zero". We're pretty forgiving.
VerifySimilar() {
prof1="$TMPDIR/$1"
exec1="$2"
prof2="$TMPDIR/$3"
exec2="$4"
mult="$5"
# We are careful not to put exec1 and exec2 in quotes, because if
# they are the empty string, it means we want to use the 1-arg
# version of pprof.
mthread1=`"$PPROF" $PPROF_FLAGS $exec1 "$prof1" | grep test_main_thread | awk '{print $1}'`
mthread2=`"$PPROF" $PPROF_FLAGS $exec2 "$prof2" | grep test_main_thread | awk '{print $1}'`
mthread1_plus=`expr $mthread1 + 5`
mthread2_plus=`expr $mthread2 + 5`
if [ -z "$mthread1" ] || [ -z "$mthread2" ] || \
[ "$mthread1" -le 0 -o "$mthread2" -le 0 ]
# || [ `expr $mthread1_plus \* $mult` -gt `expr $mthread2_plus \* 2` -o \
# `expr $mthread1_plus \* $mult \* 2` -lt `expr $mthread2_plus` ]
then
echo
echo ">>> profile on $exec1 vs $exec2 with multiplier $mult failed:"
echo "Actual times (in profiling units) were '$mthread1' vs. '$mthread2'"
echo
RegisterFailure
fi
}
# Takes two filenames representing profiles, and optionally their
# executable scripts (these may be empty if the profiles include
# symbols), and verifies that the two profiles are identical.
VerifyIdentical() {
prof1="$TMPDIR/$1"
exec1="$2"
prof2="$TMPDIR/$3"
exec2="$4"
# We are careful not to put exec1 and exec2 in quotes, because if
# they are the empty string, it means we want to use the 1-arg
# version of pprof.
"$PPROF" $PPROF_FLAGS $exec1 "$prof1" > "$TMPDIR/out1"
"$PPROF" $PPROF_FLAGS $exec2 "$prof2" > "$TMPDIR/out2"
diff=`diff "$TMPDIR/out1" "$TMPDIR/out2"`
if [ ! -z "$diff" ]; then
echo
echo ">>> profile doesn't match, args: $exec1 $prof1 vs. $exec2 $prof2"
echo ">>> Diff:"
echo "$diff"
echo
RegisterFailure
fi
}
# Takes a filename representing a profile, with its executable,
# and a multiplier, and verifies that the main-thread function takes
# the same amount of time as the other-threads function (possibly scaled
# by the given multiplier). Figuring out the multiplier can be tricky,
# since by design the main thread runs twice as long as each of the
# 'other' threads! It used to be "same" meant within 50%, after adding an
# noise-reducing X units to each value. But even that would often
# spuriously fail, so now it's "both non-zero". We're pretty forgiving.
VerifyAcrossThreads() {
prof1="$TMPDIR/$1"
# We need to run the script with no args to get the actual exe name
exec1="$2"
mult="$3"
# We are careful not to put exec1 in quotes, because if it is the
# empty string, it means we want to use the 1-arg version of pprof.
mthread=`$PPROF $PPROF_FLAGS $exec1 "$prof1" | grep test_main_thread | awk '{print $1}'`
othread=`$PPROF $PPROF_FLAGS $exec1 "$prof1" | grep test_other_thread | awk '{print $1}'`
if [ -z "$mthread" ] || [ -z "$othread" ] || \
[ "$mthread" -le 0 -o "$othread" -le 0 ]
# || [ `expr $mthread \* $mult \* 3` -gt `expr $othread \* 10` -o \
# `expr $mthread \* $mult \* 10` -lt `expr $othread \* 3` ]
then
echo
echo ">>> profile on $exec1 (main vs thread) with multiplier $mult failed:"
echo "Actual times (in profiling units) were '$mthread' vs. '$othread'"
echo
RegisterFailure
fi
}
echo
echo ">>> WARNING <<<"
echo "This test looks at timing information to determine correctness."
echo "If your system is loaded, the test may spuriously fail."
echo "If the test does fail with an 'Actual times' error, try running again."
echo
# profiler1 is a non-threaded version
"$PROFILER1" 50 1 "$TMPDIR/p1" || RegisterFailure
"$PROFILER1" 100 1 "$TMPDIR/p2" || RegisterFailure
VerifySimilar p1 "$PROFILER1_REALNAME" p2 "$PROFILER1_REALNAME" 2
# Verify the same thing works if we statically link
"$PROFILER2" 50 1 "$TMPDIR/p3" || RegisterFailure
"$PROFILER2" 100 1 "$TMPDIR/p4" || RegisterFailure
VerifySimilar p3 "$PROFILER2_REALNAME" p4 "$PROFILER2_REALNAME" 2
# Verify the same thing works if we specify via CPUPROFILE
CPUPROFILE="$TMPDIR/p5" "$PROFILER2" 50 || RegisterFailure
CPUPROFILE="$TMPDIR/p6" "$PROFILER2" 100 || RegisterFailure
VerifySimilar p5 "$PROFILER2_REALNAME" p6 "$PROFILER2_REALNAME" 2
CPUPROFILE="$TMPDIR/p5b" "$PROFILER3" 30 || RegisterFailure
CPUPROFILE="$TMPDIR/p5c" "$PROFILER3" 60 || RegisterFailure
VerifySimilar p5b "$PROFILER3_REALNAME" p5c "$PROFILER3_REALNAME" 2
# Now try what happens when we use threads
"$PROFILER3" 30 2 "$TMPDIR/p7" || RegisterFailure
"$PROFILER3" 60 2 "$TMPDIR/p8" || RegisterFailure
VerifySimilar p7 "$PROFILER3_REALNAME" p8 "$PROFILER3_REALNAME" 2
"$PROFILER4" 30 2 "$TMPDIR/p9" || RegisterFailure
"$PROFILER4" 60 2 "$TMPDIR/p10" || RegisterFailure
VerifySimilar p9 "$PROFILER4_REALNAME" p10 "$PROFILER4_REALNAME" 2
# More threads!
"$PROFILER4" 25 3 "$TMPDIR/p9" || RegisterFailure
"$PROFILER4" 50 3 "$TMPDIR/p10" || RegisterFailure
VerifySimilar p9 "$PROFILER4_REALNAME" p10 "$PROFILER4_REALNAME" 2
# Compare how much time the main thread takes compared to the other threads
# Recall the main thread runs twice as long as the other threads, by design.
"$PROFILER4" 20 4 "$TMPDIR/p11" || RegisterFailure
VerifyAcrossThreads p11 "$PROFILER4_REALNAME" 2
# Test symbol save and restore
"$PROFILER1" 50 1 "$TMPDIR/p12" || RegisterFailure
"$PPROF" $PPROF_FLAGS "$PROFILER1_REALNAME" "$TMPDIR/p12" --raw \
>"$TMPDIR/p13" 2>/dev/null || RegisterFailure
VerifyIdentical p12 "$PROFILER1_REALNAME" p13 "" || RegisterFailure
"$PROFILER3" 30 2 "$TMPDIR/p14" || RegisterFailure
"$PPROF" $PPROF_FLAGS "$PROFILER3_REALNAME" "$TMPDIR/p14" --raw \
>"$TMPDIR/p15" 2>/dev/null || RegisterFailure
VerifyIdentical p14 "$PROFILER3_REALNAME" p15 "" || RegisterFailure
# Test using ITIMER_REAL instead of ITIMER_PROF.
env CPUPROFILE_REALTIME=1 "$PROFILER3" 30 2 "$TMPDIR/p16" || RegisterFailure
env CPUPROFILE_REALTIME=1 "$PROFILER3" 60 2 "$TMPDIR/p17" || RegisterFailure
VerifySimilar p16 "$PROFILER3_REALNAME" p17 "$PROFILER3_REALNAME" 2
# Make sure that when we have a process with a fork, the profiles don't
# clobber each other
CPUPROFILE="$TMPDIR/pfork" "$PROFILER1" 1 -2 || RegisterFailure
n=`ls $TMPDIR/pfork* | wc -l`
if [ $n != 3 ]; then
echo "FORK test FAILED: expected 3 profiles (for main + 2 children), found $n"
num_failures=`expr $num_failures + 1`
fi
rm -rf "$TMPDIR" # clean up
echo "Tests finished with $num_failures failures"
exit $num_failures
| Shell |
3D | mcellteam/mcell | libs/gperftools/src/tests/heap-checker-death_unittest.sh | .sh | 6,656 | 177 | #!/bin/sh
# Copyright (c) 2005, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ---
# Author: Maxim Lifantsev
#
# Run the heap checker unittest in a mode where it is supposed to crash and
# return an error if it doesn't.
# We expect BINDIR to be set in the environment.
# If not, we set it to some reasonable value.
BINDIR="${BINDIR:-.}"
if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then
echo "USAGE: $0 [unittest dir]"
echo " By default, unittest_dir=$BINDIR"
exit 1
fi
EXE="${1:-$BINDIR/heap-checker_unittest}"
TMPDIR="/tmp/heap_check_death_info"
ALARM() {
# You need perl to run pprof, so I assume it's installed
perl -e '
$timeout=$ARGV[0]; shift;
$retval = 255; # the default retval, for the case where we timed out
eval { # need to run in an eval-block to trigger during system()
local $SIG{ALRM} = sub { die "alarm\n" }; # \n is required!
alarm $timeout;
$retval = system(@ARGV);
# Make retval bash-style: exit status, or 128+n if terminated by signal n
$retval = ($retval & 127) ? (128 + $retval) : ($retval >> 8);
alarm 0;
};
exit $retval; # return system()-retval, or 255 if system() never returned
' "$@"
}
# $1: timeout for alarm;
# $2: regexp of expected exit code(s);
# $3: regexp to match a line in the output;
# $4: regexp to not match a line in the output;
# $5+ args to pass to $EXE
Test() {
# Note: make sure these varnames don't conflict with any vars outside Test()!
timeout="$1"
shift
expected_ec="$1"
shift
expected_regexp="$1"
shift
unexpected_regexp="$1"
shift
echo -n "Testing $EXE with $@ ... "
output="$TMPDIR/output"
ALARM $timeout env "$@" $EXE > "$output" 2>&1
actual_ec=$?
ec_ok=`expr "$actual_ec" : "$expected_ec$" >/dev/null || echo false`
matches_ok=`test -z "$expected_regexp" || \
grep "$expected_regexp" "$output" >/dev/null 2>&1 || echo false`
negmatches_ok=`test -z "$unexpected_regexp" || \
! grep "$unexpected_regexp" "$output" >/dev/null 2>&1 || echo false`
if $ec_ok && $matches_ok && $negmatches_ok; then
echo "PASS"
return 0 # 0: success
fi
# If we get here, we failed. Now we just need to report why
echo "FAIL"
if [ $actual_ec -eq 255 ]; then # 255 == SIGTERM due to $ALARM
echo "Test was taking unexpectedly long time to run and so we aborted it."
echo "Try the test case manually or raise the timeout from $timeout"
echo "to distinguish test slowness from a real problem."
else
$ec_ok || \
echo "Wrong exit code: expected: '$expected_ec'; actual: $actual_ec"
$matches_ok || \
echo "Output did not match '$expected_regexp'"
$negmatches_ok || \
echo "Output unexpectedly matched '$unexpected_regexp'"
fi
echo "Output from failed run:"
echo "---"
cat "$output"
echo "---"
return 1 # 1: failure
}
TMPDIR=/tmp/heap_check_death_info
rm -rf $TMPDIR || exit 1
mkdir $TMPDIR || exit 2
export HEAPCHECK=strict # default mode
# These invocations should pass (0 == PASS):
# This tests that turning leak-checker off dynamically works fine
Test 120 0 "^PASS$" "" HEAPCHECK="" || exit 1
# This disables threads so we can cause leaks reliably and test finding them
Test 120 0 "^PASS$" "" HEAP_CHECKER_TEST_NO_THREADS=1 || exit 2
# Test that --test_cancel_global_check works
Test 20 0 "Canceling .* whole-program .* leak check$" "" \
HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_TEST_CANCEL_GLOBAL_CHECK=1 || exit 3
Test 20 0 "Canceling .* whole-program .* leak check$" "" \
HEAP_CHECKER_TEST_TEST_LOOP_LEAK=1 HEAP_CHECKER_TEST_TEST_CANCEL_GLOBAL_CHECK=1 || exit 4
# Test that very early log messages are present and controllable:
EARLY_MSG="Starting tracking the heap$"
Test 60 0 "$EARLY_MSG" "" \
HEAPCHECK="" HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 \
PERFTOOLS_VERBOSE=10 || exit 5
Test 60 0 "MemoryRegionMap Init$" "" \
HEAPCHECK="" HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 \
PERFTOOLS_VERBOSE=11 || exit 6
Test 60 0 "" "$EARLY_MSG" \
HEAPCHECK="" HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 \
PERFTOOLS_VERBOSE=-11 || exit 7
# These invocations should fail with very high probability,
# rather than return 0 or hang (1 == exit(1), 134 == abort(), 139 = SIGSEGV):
Test 60 1 "Exiting .* because of .* leaks$" "" \
HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 || exit 8
Test 60 1 "Exiting .* because of .* leaks$" "" \
HEAP_CHECKER_TEST_TEST_LOOP_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 || exit 9
# Test that we produce a reasonable textual leak report.
Test 60 1 "MakeALeak" "" \
HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 \
|| exit 10
# Test that very early log messages are present and controllable:
Test 60 1 "Starting tracking the heap$" "" \
HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 PERFTOOLS_VERBOSE=10 \
|| exit 11
Test 60 1 "" "Starting tracking the heap" \
HEAP_CHECKER_TEST_TEST_LEAK=1 HEAP_CHECKER_TEST_NO_THREADS=1 PERFTOOLS_VERBOSE=-10 \
|| exit 12
cd / # so we're not in TMPDIR when we delete it
rm -rf $TMPDIR
echo "PASS"
exit 0
| Shell |
3D | mcellteam/mcell | libs/gperftools/src/tests/sampler_test.cc | .cc | 22,220 | 632 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// All Rights Reserved.
//
// Author: Daniel Ford
//
// Checks basic properties of the sampler
#include "config_for_unittests.h"
#include <stdlib.h> // defines posix_memalign
#include <stdio.h> // for the printf at the end
#if defined HAVE_STDINT_H
#include <stdint.h> // to get uintptr_t
#elif defined HAVE_INTTYPES_H
#include <inttypes.h> // another place uintptr_t might be defined
#endif
#include <sys/types.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include "base/logging.h"
#include "base/commandlineflags.h"
#include "sampler.h" // The Sampler class being tested
using std::sort;
using std::min;
using std::max;
using std::vector;
using std::abs;
vector<void (*)()> g_testlist; // the tests to run
#define TEST(a, b) \
struct Test_##a##_##b { \
Test_##a##_##b() { g_testlist.push_back(&Run); } \
static void Run(); \
}; \
static Test_##a##_##b g_test_##a##_##b; \
void Test_##a##_##b::Run()
static int RUN_ALL_TESTS() {
vector<void (*)()>::const_iterator it;
for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
(*it)(); // The test will error-exit if there's a problem.
}
fprintf(stderr, "\nPassed %d tests\n\nPASS\n", (int)g_testlist.size());
return 0;
}
#undef LOG // defined in base/logging.h
// Ideally, we'd put the newline at the end, but this hack puts the
// newline at the end of the previous log message, which is good enough :-)
#define LOG(level) std::cerr << "\n"
static std::string StringPrintf(const char* format, ...) {
char buf[256]; // should be big enough for all logging
va_list ap;
va_start(ap, format);
perftools_vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
return buf;
}
namespace {
template<typename T> class scoped_array {
public:
scoped_array(T* p) : p_(p) { }
~scoped_array() { delete[] p_; }
const T* get() const { return p_; }
T* get() { return p_; }
T& operator[](int i) { return p_[i]; }
private:
T* p_;
};
}
// Note that these tests are stochastic.
// This mean that the chance of correct code passing the test is,
// in the case of 5 standard deviations:
// kSigmas=5: ~99.99994267%
// in the case of 4 standard deviations:
// kSigmas=4: ~99.993666%
static const double kSigmas = 4;
static const size_t kSamplingInterval = 512*1024;
// Tests that GetSamplePeriod returns the expected value
// which is 1<<19
TEST(Sampler, TestGetSamplePeriod) {
tcmalloc::Sampler sampler;
sampler.Init(1);
uint64_t sample_period;
sample_period = sampler.GetSamplePeriod();
CHECK_GT(sample_period, 0);
}
// Tests of the quality of the random numbers generated
// This uses the Anderson Darling test for uniformity.
// See "Evaluating the Anderson-Darling Distribution" by Marsaglia
// for details.
// Short cut version of ADinf(z), z>0 (from Marsaglia)
// This returns the p-value for Anderson Darling statistic in
// the limit as n-> infinity. For finite n, apply the error fix below.
double AndersonDarlingInf(double z) {
if (z < 2) {
return exp(-1.2337141 / z) / sqrt(z) * (2.00012 + (0.247105 -
(0.0649821 - (0.0347962 - (0.011672 - 0.00168691
* z) * z) * z) * z) * z);
}
return exp( - exp(1.0776 - (2.30695 - (0.43424 - (0.082433 -
(0.008056 - 0.0003146 * z) * z) * z) * z) * z));
}
// Corrects the approximation error in AndersonDarlingInf for small values of n
// Add this to AndersonDarlingInf to get a better approximation
// (from Marsaglia)
double AndersonDarlingErrFix(int n, double x) {
if (x > 0.8) {
return (-130.2137 + (745.2337 - (1705.091 - (1950.646 -
(1116.360 - 255.7844 * x) * x) * x) * x) * x) / n;
}
double cutoff = 0.01265 + 0.1757 / n;
double t;
if (x < cutoff) {
t = x / cutoff;
t = sqrt(t) * (1 - t) * (49 * t - 102);
return t * (0.0037 / (n * n) + 0.00078 / n + 0.00006) / n;
} else {
t = (x - cutoff) / (0.8 - cutoff);
t = -0.00022633 + (6.54034 - (14.6538 - (14.458 - (8.259 - 1.91864
* t) * t) * t) * t) * t;
return t * (0.04213 + 0.01365 / n) / n;
}
}
// Returns the AndersonDarling p-value given n and the value of the statistic
double AndersonDarlingPValue(int n, double z) {
double ad = AndersonDarlingInf(z);
double errfix = AndersonDarlingErrFix(n, ad);
return ad + errfix;
}
double AndersonDarlingStatistic(int n, double* random_sample) {
double ad_sum = 0;
for (int i = 0; i < n; i++) {
ad_sum += (2*i + 1) * log(random_sample[i] * (1 - random_sample[n-1-i]));
}
double ad_statistic = - n - 1/static_cast<double>(n) * ad_sum;
return ad_statistic;
}
// Tests if the array of doubles is uniformly distributed.
// Returns the p-value of the Anderson Darling Statistic
// for the given set of sorted random doubles
// See "Evaluating the Anderson-Darling Distribution" by
// Marsaglia and Marsaglia for details.
double AndersonDarlingTest(int n, double* random_sample) {
double ad_statistic = AndersonDarlingStatistic(n, random_sample);
LOG(INFO) << StringPrintf("AD stat = %f, n=%d\n", ad_statistic, n);
double p = AndersonDarlingPValue(n, ad_statistic);
return p;
}
// Test the AD Test. The value of the statistic should go to zero as n->infty
// Not run as part of regular tests
void ADTestTest(int n) {
scoped_array<double> random_sample(new double[n]);
for (int i = 0; i < n; i++) {
random_sample[i] = (i+0.01)/n;
}
sort(random_sample.get(), random_sample.get() + n);
double ad_stat = AndersonDarlingStatistic(n, random_sample.get());
LOG(INFO) << StringPrintf("Testing the AD test. n=%d, ad_stat = %f",
n, ad_stat);
}
// Print the CDF of the distribution of the Anderson-Darling Statistic
// Used for checking the Anderson-Darling Test
// Not run as part of regular tests
void ADCDF() {
for (int i = 1; i < 40; i++) {
double x = i/10.0;
LOG(INFO) << "x= " << x << " adpv= "
<< AndersonDarlingPValue(100, x) << ", "
<< AndersonDarlingPValue(1000, x);
}
}
// Testing that NextRandom generates uniform
// random numbers.
// Applies the Anderson-Darling test for uniformity
void TestNextRandom(int n) {
tcmalloc::Sampler sampler;
sampler.Init(1);
uint64_t x = 1;
// This assumes that the prng returns 48 bit numbers
uint64_t max_prng_value = static_cast<uint64_t>(1)<<48;
// Initialize
for (int i = 1; i <= 20; i++) { // 20 mimics sampler.Init()
x = sampler.NextRandom(x);
}
scoped_array<uint64_t> int_random_sample(new uint64_t[n]);
// Collect samples
for (int i = 0; i < n; i++) {
int_random_sample[i] = x;
x = sampler.NextRandom(x);
}
// First sort them...
sort(int_random_sample.get(), int_random_sample.get() + n);
scoped_array<double> random_sample(new double[n]);
// Convert them to uniform randoms (in the range [0,1])
for (int i = 0; i < n; i++) {
random_sample[i] = static_cast<double>(int_random_sample[i])/max_prng_value;
}
// Now compute the Anderson-Darling statistic
double ad_pvalue = AndersonDarlingTest(n, random_sample.get());
LOG(INFO) << StringPrintf("pvalue for AndersonDarlingTest "
"with n= %d is p= %f\n", n, ad_pvalue);
CHECK_GT(min(ad_pvalue, 1 - ad_pvalue), 0.0001);
// << StringPrintf("prng is not uniform, %d\n", n);
}
TEST(Sampler, TestNextRandom_MultipleValues) {
TestNextRandom(10); // Check short-range correlation
TestNextRandom(100);
TestNextRandom(1000);
TestNextRandom(10000); // Make sure there's no systematic error
}
// Tests that PickNextSamplePeriod generates
// geometrically distributed random numbers.
// First converts to uniforms then applied the
// Anderson-Darling test for uniformity.
void TestPickNextSample(int n) {
tcmalloc::Sampler sampler;
sampler.Init(1);
scoped_array<uint64_t> int_random_sample(new uint64_t[n]);
int sample_period = sampler.GetSamplePeriod();
int ones_count = 0;
for (int i = 0; i < n; i++) {
int_random_sample[i] = sampler.PickNextSamplingPoint();
CHECK_GE(int_random_sample[i], 1);
if (int_random_sample[i] == 1) {
ones_count += 1;
}
CHECK_LT(ones_count, 4); // << " out of " << i << " samples.";
}
// First sort them...
sort(int_random_sample.get(), int_random_sample.get() + n);
scoped_array<double> random_sample(new double[n]);
// Convert them to uniform random numbers
// by applying the geometric CDF
for (int i = 0; i < n; i++) {
random_sample[i] = 1 - exp(-static_cast<double>(int_random_sample[i])
/ sample_period);
}
// Now compute the Anderson-Darling statistic
double geom_ad_pvalue = AndersonDarlingTest(n, random_sample.get());
LOG(INFO) << StringPrintf("pvalue for geometric AndersonDarlingTest "
"with n= %d is p= %f\n", n, geom_ad_pvalue);
CHECK_GT(min(geom_ad_pvalue, 1 - geom_ad_pvalue), 0.0001);
// << "PickNextSamplingPoint does not produce good "
// "geometric/exponential random numbers\n";
}
TEST(Sampler, TestPickNextSample_MultipleValues) {
TestPickNextSample(10); // Make sure the first few are good (enough)
TestPickNextSample(100);
TestPickNextSample(1000);
TestPickNextSample(10000); // Make sure there's no systematic error
}
// This is superceeded by the Anderson-Darling Test
// and it not run now.
// Tests how fast nearby values are spread out with LRand64
// The purpose of this code is to determine how many
// steps to apply to the seed during initialization
void TestLRand64Spread() {
tcmalloc::Sampler sampler;
sampler.Init(1);
uint64_t current_value;
printf("Testing LRand64 Spread\n");
for (int i = 1; i < 10; i++) {
printf("%d ", i);
current_value = i;
for (int j = 1; j < 100; j++) {
current_value = sampler.NextRandom(current_value);
}
LOG(INFO) << current_value;
}
}
// Futher tests
bool CheckMean(size_t mean, int num_samples) {
tcmalloc::Sampler sampler;
sampler.Init(1);
size_t total = 0;
for (int i = 0; i < num_samples; i++) {
total += sampler.PickNextSamplingPoint();
}
double empirical_mean = total / static_cast<double>(num_samples);
double expected_sd = mean / pow(num_samples * 1.0, 0.5);
return(fabs(mean-empirical_mean) < expected_sd * kSigmas);
}
// Prints a sequence so you can look at the distribution
void OutputSequence(int sequence_length) {
tcmalloc::Sampler sampler;
sampler.Init(1);
size_t next_step;
for (int i = 0; i< sequence_length; i++) {
next_step = sampler.PickNextSamplingPoint();
LOG(INFO) << next_step;
}
}
double StandardDeviationsErrorInSample(
int total_samples, int picked_samples,
int alloc_size, int sampling_interval) {
double p = 1 - exp(-(static_cast<double>(alloc_size) / sampling_interval));
double expected_samples = total_samples * p;
double sd = pow(p*(1-p)*total_samples, 0.5);
return((picked_samples - expected_samples) / sd);
}
TEST(Sampler, LargeAndSmallAllocs_CombinedTest) {
tcmalloc::Sampler sampler;
sampler.Init(1);
int counter_big = 0;
int counter_small = 0;
int size_big = 129*8*1024+1;
int size_small = 1024*8;
int num_iters = 128*4*8;
// Allocate in mixed chunks
for (int i = 0; i < num_iters; i++) {
if (!sampler.RecordAllocation(size_big)) {
counter_big += 1;
}
for (int i = 0; i < 129; i++) {
if (!sampler.RecordAllocation(size_small)) {
counter_small += 1;
}
}
}
// Now test that there are the right number of each
double large_allocs_sds =
StandardDeviationsErrorInSample(num_iters, counter_big,
size_big, kSamplingInterval);
double small_allocs_sds =
StandardDeviationsErrorInSample(num_iters*129, counter_small,
size_small, kSamplingInterval);
LOG(INFO) << StringPrintf("large_allocs_sds = %f\n", large_allocs_sds);
LOG(INFO) << StringPrintf("small_allocs_sds = %f\n", small_allocs_sds);
CHECK_LE(fabs(large_allocs_sds), kSigmas);
CHECK_LE(fabs(small_allocs_sds), kSigmas);
}
// Tests whether the mean is about right over 1000 samples
TEST(Sampler, IsMeanRight) {
CHECK(CheckMean(kSamplingInterval, 1000));
}
// This flag is for the OldSampler class to use
const int64 FLAGS_mock_tcmalloc_sample_parameter = 1<<19;
// A cut down and slightly refactored version of the old Sampler
class OldSampler {
public:
void Init(uint32_t seed);
void Cleanup() {}
// Record allocation of "k" bytes. Return true iff allocation
// should be sampled
bool SampleAllocation(size_t k);
// Generate a geometric with mean 1M (or FLAG value)
void PickNextSample(size_t k);
// Initialize the statics for the Sample class
static void InitStatics() {
sample_period = 1048583;
}
size_t bytes_until_sample_;
private:
uint32_t rnd_; // Cheap random number generator
static uint64_t sample_period;
// Should be a prime just above a power of 2:
// 2, 5, 11, 17, 37, 67, 131, 257,
// 521, 1031, 2053, 4099, 8209, 16411,
// 32771, 65537, 131101, 262147, 524309, 1048583,
// 2097169, 4194319, 8388617, 16777259, 33554467
};
// Statics for OldSampler
uint64_t OldSampler::sample_period;
void OldSampler::Init(uint32_t seed) {
// Initialize PRNG -- run it for a bit to get to good values
if (seed != 0) {
rnd_ = seed;
} else {
rnd_ = 12345;
}
bytes_until_sample_ = 0;
for (int i = 0; i < 100; i++) {
PickNextSample(sample_period * 2);
}
};
// A cut-down version of the old PickNextSampleRoutine
void OldSampler::PickNextSample(size_t k) {
// Make next "random" number
// x^32+x^22+x^2+x^1+1 is a primitive polynomial for random numbers
static const uint32_t kPoly = (1 << 22) | (1 << 2) | (1 << 1) | (1 << 0);
uint32_t r = rnd_;
rnd_ = (r << 1) ^ ((static_cast<int32_t>(r) >> 31) & kPoly);
// Next point is "rnd_ % (sample_period)". I.e., average
// increment is "sample_period/2".
const int flag_value = FLAGS_mock_tcmalloc_sample_parameter;
static int last_flag_value = -1;
if (flag_value != last_flag_value) {
// There should be a spinlock here, but this code is
// for benchmarking only.
sample_period = 1048583;
last_flag_value = flag_value;
}
bytes_until_sample_ += rnd_ % sample_period;
if (k > (static_cast<size_t>(-1) >> 2)) {
// If the user has asked for a huge allocation then it is possible
// for the code below to loop infinitely. Just return (note that
// this throws off the sampling accuracy somewhat, but a user who
// is allocating more than 1G of memory at a time can live with a
// minor inaccuracy in profiling of small allocations, and also
// would rather not wait for the loop below to terminate).
return;
}
while (bytes_until_sample_ < k) {
// Increase bytes_until_sample_ by enough average sampling periods
// (sample_period >> 1) to allow us to sample past the current
// allocation.
bytes_until_sample_ += (sample_period >> 1);
}
bytes_until_sample_ -= k;
}
inline bool OldSampler::SampleAllocation(size_t k) {
if (bytes_until_sample_ < k) {
PickNextSample(k);
return true;
} else {
bytes_until_sample_ -= k;
return false;
}
}
// This checks that the stated maximum value for the
// tcmalloc_sample_parameter flag never overflows bytes_until_sample_
TEST(Sampler, bytes_until_sample_Overflow_Underflow) {
tcmalloc::Sampler sampler;
sampler.Init(1);
uint64_t one = 1;
// sample_parameter = 0; // To test the edge case
uint64_t sample_parameter_array[4] = {0, 1, one<<19, one<<58};
for (int i = 0; i < 4; i++) {
uint64_t sample_parameter = sample_parameter_array[i];
LOG(INFO) << "sample_parameter = " << sample_parameter;
double sample_scaling = - log(2.0) * sample_parameter;
// Take the top 26 bits as the random number
// (This plus the 1<<26 sampling bound give a max step possible of
// 1209424308 bytes.)
const uint64_t prng_mod_power = 48; // Number of bits in prng
// First, check the largest_prng value
uint64_t largest_prng_value = (static_cast<uint64_t>(1)<<48) - 1;
double q = (largest_prng_value >> (prng_mod_power - 26)) + 1.0;
LOG(INFO) << StringPrintf("q = %f\n", q);
LOG(INFO) << StringPrintf("log2(q) = %f\n", log(q)/log(2.0));
uint64_t smallest_sample_step
= static_cast<uint64_t>(min(log2(q) - 26, 0.0)
* sample_scaling + 1);
LOG(INFO) << "Smallest sample step is " << smallest_sample_step;
uint64_t cutoff = static_cast<uint64_t>(10)
* (sample_parameter/(one<<24) + 1);
LOG(INFO) << "Acceptable value is < " << cutoff;
// This checks that the answer is "small" and positive
CHECK_LE(smallest_sample_step, cutoff);
// Next, check with the smallest prng value
uint64_t smallest_prng_value = 0;
q = (smallest_prng_value >> (prng_mod_power - 26)) + 1.0;
LOG(INFO) << StringPrintf("q = %f\n", q);
uint64_t largest_sample_step
= static_cast<uint64_t>(min(log2(q) - 26, 0.0)
* sample_scaling + 1);
LOG(INFO) << "Largest sample step is " << largest_sample_step;
CHECK_LE(largest_sample_step, one<<63);
CHECK_GE(largest_sample_step, smallest_sample_step);
}
}
// Test that NextRand is in the right range. Unfortunately, this is a
// stochastic test which could miss problems.
TEST(Sampler, NextRand_range) {
tcmalloc::Sampler sampler;
sampler.Init(1);
uint64_t one = 1;
// The next number should be (one << 48) - 1
uint64_t max_value = (one << 48) - 1;
uint64_t x = (one << 55);
int n = 22; // 27;
LOG(INFO) << "Running sampler.NextRandom 1<<" << n << " times";
for (int i = 1; i <= (1<<n); i++) { // 20 mimics sampler.Init()
x = sampler.NextRandom(x);
CHECK_LE(x, max_value);
}
}
// Tests certain arithmetic operations to make sure they compute what we
// expect them too (for testing across different platforms)
TEST(Sampler, arithmetic_1) {
tcmalloc::Sampler sampler;
sampler.Init(1);
uint64_t rnd; // our 48 bit random number, which we don't trust
const uint64_t prng_mod_power = 48;
uint64_t one = 1;
rnd = one;
uint64_t max_value = (one << 48) - 1;
for (int i = 1; i <= (1>>27); i++) { // 20 mimics sampler.Init()
rnd = sampler.NextRandom(rnd);
CHECK_LE(rnd, max_value);
double q = (rnd >> (prng_mod_power - 26)) + 1.0;
CHECK_GE(q, 0); // << rnd << " " << prng_mod_power;
}
// Test some potentially out of bounds value for rnd
for (int i = 1; i <= 63; i++) {
rnd = one << i;
double q = (rnd >> (prng_mod_power - 26)) + 1.0;
LOG(INFO) << "rnd = " << rnd << " i=" << i << " q=" << q;
CHECK_GE(q, 0);
// << " rnd=" << rnd << " i=" << i << " prng_mod_power" << prng_mod_power;
}
}
void test_arithmetic(uint64_t rnd) {
const uint64_t prng_mod_power = 48; // Number of bits in prng
uint64_t shifted_rnd = rnd >> (prng_mod_power - 26);
CHECK_GE(shifted_rnd, 0);
CHECK_LT(shifted_rnd, (1<<26));
LOG(INFO) << shifted_rnd;
LOG(INFO) << static_cast<double>(shifted_rnd);
CHECK_GE(static_cast<double>(static_cast<uint32_t>(shifted_rnd)), 0);
// << " rnd=" << rnd << " srnd=" << shifted_rnd;
CHECK_GE(static_cast<double>(shifted_rnd), 0);
// << " rnd=" << rnd << " srnd=" << shifted_rnd;
double q = static_cast<double>(shifted_rnd) + 1.0;
CHECK_GT(q, 0);
}
// Tests certain arithmetic operations to make sure they compute what we
// expect them too (for testing across different platforms)
// know bad values under with -c dbg --cpu piii for _some_ binaries:
// rnd=227453640600554
// shifted_rnd=54229173
// (hard to reproduce)
TEST(Sampler, arithmetic_2) {
uint64_t rnd = 227453640600554LL;
test_arithmetic(rnd);
}
// It's not really a test, but it's good to know
TEST(Sample, size_of_class) {
tcmalloc::Sampler sampler;
sampler.Init(1);
LOG(INFO) << "Size of Sampler class is: " << sizeof(tcmalloc::Sampler);
LOG(INFO) << "Size of Sampler object is: " << sizeof(sampler);
}
// Make sure sampling is enabled, or the tests won't work right.
DECLARE_int64(tcmalloc_sample_parameter);
int main(int argc, char **argv) {
if (FLAGS_tcmalloc_sample_parameter == 0)
FLAGS_tcmalloc_sample_parameter = 524288;
return RUN_ALL_TESTS();
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/realloc_unittest.cc | .cc | 4,253 | 126 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2004, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Sanjay Ghemawat
//
// Test realloc() functionality
#include "config_for_unittests.h"
#include <assert.h> // for assert
#include <stdio.h>
#include <stddef.h> // for size_t, NULL
#include <stdlib.h> // for free, malloc, realloc
#include <algorithm> // for min
#include "base/logging.h"
using std::min;
// Fill a buffer of the specified size with a predetermined pattern
static void Fill(unsigned char* buffer, int n) {
for (int i = 0; i < n; i++) {
buffer[i] = (i & 0xff);
}
}
// Check that the specified buffer has the predetermined pattern
// generated by Fill()
static bool Valid(unsigned char* buffer, int n) {
for (int i = 0; i < n; i++) {
if (buffer[i] != (i & 0xff)) {
return false;
}
}
return true;
}
// Return the next interesting size/delta to check. Returns -1 if no more.
static int NextSize(int size) {
if (size < 100) {
return size+1;
} else if (size < 100000) {
// Find next power of two
int power = 1;
while (power < size) {
power <<= 1;
}
// Yield (power-1, power, power+1)
if (size < power-1) {
return power-1;
} else if (size == power-1) {
return power;
} else {
assert(size == power);
return power+1;
}
} else {
return -1;
}
}
int main(int argc, char** argv) {
for (int src_size = 0; src_size >= 0; src_size = NextSize(src_size)) {
for (int dst_size = 0; dst_size >= 0; dst_size = NextSize(dst_size)) {
unsigned char* src = (unsigned char*) malloc(src_size);
Fill(src, src_size);
unsigned char* dst = (unsigned char*) realloc(src, dst_size);
CHECK(Valid(dst, min(src_size, dst_size)));
Fill(dst, dst_size);
CHECK(Valid(dst, dst_size));
if (dst != NULL) free(dst);
}
}
// Now make sure realloc works correctly even when we overflow the
// packed cache, so some entries are evicted from the cache.
// The cache has 2^12 entries, keyed by page number.
const int kNumEntries = 1 << 14;
int** p = (int**)malloc(sizeof(*p) * kNumEntries);
int sum = 0;
for (int i = 0; i < kNumEntries; i++) {
p[i] = (int*)malloc(8192); // no page size is likely to be bigger
p[i][1000] = i; // use memory deep in the heart of p
}
for (int i = 0; i < kNumEntries; i++) {
p[i] = (int*)realloc(p[i], 9000);
}
for (int i = 0; i < kNumEntries; i++) {
sum += p[i][1000];
free(p[i]);
}
CHECK_EQ(kNumEntries/2 * (kNumEntries - 1), sum); // assume kNE is even
free(p);
printf("PASS\n");
return 0;
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/testutil.h | .h | 2,986 | 63 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
// Author: Craig Silverstein
#ifndef TCMALLOC_TOOLS_TESTUTIL_H_
#define TCMALLOC_TOOLS_TESTUTIL_H_
// Run a function in a thread of its own and wait for it to finish.
// The function you pass in must have the signature
// void MyFunction();
extern "C" void RunThread(void (*fn)());
// Run a function X times, in X threads, and wait for them all to finish.
// The function you pass in must have the signature
// void MyFunction();
extern "C" void RunManyThreads(void (*fn)(), int count);
// The 'advanced' version: run a function X times, in X threads, and
// wait for them all to finish. Give them all the specified stack-size.
// (If you're curious why this takes a stacksize and the others don't,
// it's because the one client of this fn wanted to specify stacksize. :-) )
// The function you pass in must have the signature
// void MyFunction(int idx);
// where idx is the index of the thread (which of the X threads this is).
extern "C" void RunManyThreadsWithId(void (*fn)(int), int count, int stacksize);
// When compiled 64-bit and run on systems with swap several unittests will end
// up trying to consume all of RAM+swap, and that can take quite some time. By
// limiting the address-space size we get sufficient coverage without blowing
// out job limits.
void SetTestResourceLimit();
#endif // TCMALLOC_TOOLS_TESTUTIL_H_
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/malloc_extension_c_test.c | .c | 5,975 | 183 | /* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ---
* Author: Craig Silverstein
*
* This tests the c shims: malloc_extension_c.h and malloc_hook_c.h.
* Mostly, we'll just care that these shims compile under gcc
* (*not* g++!)
*
* NOTE: this is C code, not C++ code!
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h> /* for size_t */
#include <gperftools/malloc_extension_c.h>
#include <gperftools/malloc_hook_c.h>
#define FAIL(msg) do { \
fprintf(stderr, "FATAL ERROR: %s\n", msg); \
exit(1); \
} while (0)
static int g_new_hook_calls = 0;
static int g_delete_hook_calls = 0;
void TestNewHook(const void* ptr, size_t size) {
g_new_hook_calls++;
}
void TestDeleteHook(const void* ptr) {
g_delete_hook_calls++;
}
static
void *forced_malloc(size_t size)
{
extern void *tc_malloc(size_t);
void *rv = tc_malloc(size);
if (!rv) {
FAIL("malloc is not supposed to fail here");
}
return rv;
}
void TestMallocHook(void) {
/* TODO(csilvers): figure out why we get:
* E0100 00:00:00.000000 7383 malloc_hook.cc:244] RAW: google_malloc section is missing, thus InHookCaller is broken!
*/
#if 0
void* result[5];
if (MallocHook_GetCallerStackTrace(result, sizeof(result)/sizeof(*result),
0) < 2) { /* should have this and main */
FAIL("GetCallerStackTrace failed");
}
#endif
if (!MallocHook_AddNewHook(&TestNewHook)) {
FAIL("Failed to add new hook");
}
if (!MallocHook_AddDeleteHook(&TestDeleteHook)) {
FAIL("Failed to add delete hook");
}
free(forced_malloc(10));
free(forced_malloc(20));
if (g_new_hook_calls != 2) {
FAIL("Wrong number of calls to the new hook");
}
if (g_delete_hook_calls != 2) {
FAIL("Wrong number of calls to the delete hook");
}
if (!MallocHook_RemoveNewHook(&TestNewHook)) {
FAIL("Failed to remove new hook");
}
if (!MallocHook_RemoveDeleteHook(&TestDeleteHook)) {
FAIL("Failed to remove delete hook");
}
free(forced_malloc(10));
free(forced_malloc(20));
if (g_new_hook_calls != 2) {
FAIL("Wrong number of calls to the new hook");
}
MallocHook_SetNewHook(&TestNewHook);
MallocHook_SetDeleteHook(&TestDeleteHook);
free(forced_malloc(10));
free(forced_malloc(20));
if (g_new_hook_calls != 4) {
FAIL("Wrong number of calls to the singular new hook");
}
if (MallocHook_SetNewHook(NULL) == NULL) {
FAIL("Failed to set new hook");
}
if (MallocHook_SetDeleteHook(NULL) == NULL) {
FAIL("Failed to set delete hook");
}
}
void TestMallocExtension(void) {
int blocks;
size_t total;
int hist[64];
char buffer[200];
char* x = (char*)malloc(10);
MallocExtension_VerifyAllMemory();
MallocExtension_VerifyMallocMemory(x);
MallocExtension_MallocMemoryStats(&blocks, &total, hist);
MallocExtension_GetStats(buffer, sizeof(buffer));
if (!MallocExtension_GetNumericProperty("generic.current_allocated_bytes",
&total)) {
FAIL("GetNumericProperty failed for generic.current_allocated_bytes");
}
if (total < 10) {
FAIL("GetNumericProperty had bad return for generic.current_allocated_bytes");
}
if (!MallocExtension_GetNumericProperty("generic.current_allocated_bytes",
&total)) {
FAIL("GetNumericProperty failed for generic.current_allocated_bytes");
}
MallocExtension_MarkThreadIdle();
MallocExtension_MarkThreadBusy();
MallocExtension_ReleaseToSystem(1);
MallocExtension_ReleaseFreeMemory();
if (MallocExtension_GetEstimatedAllocatedSize(10) < 10) {
FAIL("GetEstimatedAllocatedSize returned a bad value (too small)");
}
if (MallocExtension_GetAllocatedSize(x) < 10) {
FAIL("GetEstimatedAllocatedSize returned a bad value (too small)");
}
if (MallocExtension_GetOwnership(x) != MallocExtension_kOwned) {
FAIL("DidAllocatePtr returned a bad value (kNotOwned)");
}
/* TODO(csilvers): this relies on undocumented behavior that
GetOwnership works on stack-allocated variables. Use a better test. */
if (MallocExtension_GetOwnership(hist) != MallocExtension_kNotOwned) {
FAIL("DidAllocatePtr returned a bad value (kOwned)");
}
free(x);
}
int main(int argc, char** argv) {
TestMallocHook();
TestMallocExtension();
printf("PASS\n");
return 0;
}
| C |
3D | mcellteam/mcell | libs/gperftools/src/tests/profile-handler_unittest.cc | .cc | 12,612 | 399 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright 2009 Google Inc. All Rights Reserved.
// Author: Nabeel Mian (nabeelmian@google.com)
// Chris Demetriou (cgd@google.com)
//
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
//
//
// This file contains the unit tests for profile-handler.h interface.
#include "config.h"
#include "profile-handler.h"
#include <assert.h>
#include <pthread.h>
#include <sys/time.h>
#include <time.h>
#include "base/logging.h"
#include "base/simple_mutex.h"
// Some helpful macros for the test class
#define TEST_F(cls, fn) void cls :: fn()
// Do we expect the profiler to be enabled?
DEFINE_bool(test_profiler_enabled, true,
"expect profiler to be enabled during tests");
namespace {
// TODO(csilvers): error-checking on the pthreads routines
class Thread {
public:
Thread() : joinable_(false) { }
virtual ~Thread() { }
void SetJoinable(bool value) { joinable_ = value; }
void Start() {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, joinable_ ? PTHREAD_CREATE_JOINABLE
: PTHREAD_CREATE_DETACHED);
pthread_create(&thread_, &attr, &DoRun, this);
pthread_attr_destroy(&attr);
}
void Join() {
assert(joinable_);
pthread_join(thread_, NULL);
}
virtual void Run() = 0;
private:
static void* DoRun(void* cls) {
ProfileHandlerRegisterThread();
reinterpret_cast<Thread*>(cls)->Run();
return NULL;
}
pthread_t thread_;
bool joinable_;
};
// Sleep interval in nano secs. ITIMER_PROF goes off only afer the specified CPU
// time is consumed. Under heavy load this process may no get scheduled in a
// timely fashion. Therefore, give enough time (20x of ProfileHandle timer
// interval 10ms (100Hz)) for this process to accumulate enought CPU time to get
// a profile tick.
int kSleepInterval = 200000000;
// Sleep interval in nano secs. To ensure that if the timer has expired it is
// reset.
int kTimerResetInterval = 5000000;
static bool linux_per_thread_timers_mode_ = false;
static int timer_type_ = ITIMER_PROF;
// Delays processing by the specified number of nano seconds. 'delay_ns'
// must be less than the number of nano seconds in a second (1000000000).
void Delay(int delay_ns) {
static const int kNumNSecInSecond = 1000000000;
EXPECT_LT(delay_ns, kNumNSecInSecond);
struct timespec delay = { 0, delay_ns };
nanosleep(&delay, 0);
}
// Checks whether the profile timer is enabled for the current thread.
bool IsTimerEnabled() {
itimerval current_timer;
EXPECT_EQ(0, getitimer(timer_type_, ¤t_timer));
if ((current_timer.it_value.tv_sec == 0) &&
(current_timer.it_value.tv_usec != 0)) {
// May be the timer has expired. Sleep for a bit and check again.
Delay(kTimerResetInterval);
EXPECT_EQ(0, getitimer(timer_type_, ¤t_timer));
}
return (current_timer.it_value.tv_sec != 0 ||
current_timer.it_value.tv_usec != 0);
}
// Dummy worker thread to accumulate cpu time.
class BusyThread : public Thread {
public:
BusyThread() : stop_work_(false) {
}
// Setter/Getters
bool stop_work() {
MutexLock lock(&mu_);
return stop_work_;
}
void set_stop_work(bool stop_work) {
MutexLock lock(&mu_);
stop_work_ = stop_work;
}
private:
// Protects stop_work_ below.
Mutex mu_;
// Whether to stop work?
bool stop_work_;
// Do work until asked to stop.
void Run() {
while (!stop_work()) {
}
}
};
class NullThread : public Thread {
private:
void Run() {
}
};
// Signal handler which tracks the profile timer ticks.
static void TickCounter(int sig, siginfo_t* sig_info, void *vuc,
void* tick_counter) {
int* counter = static_cast<int*>(tick_counter);
++(*counter);
}
// This class tests the profile-handler.h interface.
class ProfileHandlerTest {
protected:
// Determines the timer type.
static void SetUpTestCase() {
timer_type_ = (getenv("CPUPROFILE_REALTIME") ? ITIMER_REAL : ITIMER_PROF);
#if HAVE_LINUX_SIGEV_THREAD_ID
linux_per_thread_timers_mode_ = (getenv("CPUPROFILE_PER_THREAD_TIMERS") != NULL);
const char *signal_number = getenv("CPUPROFILE_TIMER_SIGNAL");
if (signal_number) {
//signal_number_ = strtol(signal_number, NULL, 0);
linux_per_thread_timers_mode_ = true;
Delay(kTimerResetInterval);
}
#endif
}
// Sets up the profile timers and SIGPROF/SIGALRM handler in a known state.
// It does the following:
// 1. Unregisters all the callbacks, stops the timer and clears out
// timer_sharing state in the ProfileHandler. This clears out any state
// left behind by the previous test or during module initialization when
// the test program was started.
// 3. Starts a busy worker thread to accumulate CPU usage.
virtual void SetUp() {
// Reset the state of ProfileHandler between each test. This unregisters
// all callbacks and stops the timer.
ProfileHandlerReset();
EXPECT_EQ(0, GetCallbackCount());
VerifyDisabled();
// Start worker to accumulate cpu usage.
StartWorker();
}
virtual void TearDown() {
ProfileHandlerReset();
// Stops the worker thread.
StopWorker();
}
// Starts a busy worker thread to accumulate cpu time. There should be only
// one busy worker running. This is required for the case where there are
// separate timers for each thread.
void StartWorker() {
busy_worker_ = new BusyThread();
busy_worker_->SetJoinable(true);
busy_worker_->Start();
// Wait for worker to start up and register with the ProfileHandler.
// TODO(nabeelmian) This may not work under very heavy load.
Delay(kSleepInterval);
}
// Stops the worker thread.
void StopWorker() {
busy_worker_->set_stop_work(true);
busy_worker_->Join();
delete busy_worker_;
}
// Gets the number of callbacks registered with the ProfileHandler.
uint32 GetCallbackCount() {
ProfileHandlerState state;
ProfileHandlerGetState(&state);
return state.callback_count;
}
// Gets the current ProfileHandler interrupt count.
uint64 GetInterruptCount() {
ProfileHandlerState state;
ProfileHandlerGetState(&state);
return state.interrupts;
}
// Verifies that a callback is correctly registered and receiving
// profile ticks.
void VerifyRegistration(const int& tick_counter) {
// Check the callback count.
EXPECT_GT(GetCallbackCount(), 0);
// Check that the profile timer is enabled.
EXPECT_EQ(FLAGS_test_profiler_enabled, linux_per_thread_timers_mode_ || IsTimerEnabled());
uint64 interrupts_before = GetInterruptCount();
// Sleep for a bit and check that tick counter is making progress.
int old_tick_count = tick_counter;
Delay(kSleepInterval);
int new_tick_count = tick_counter;
uint64 interrupts_after = GetInterruptCount();
if (FLAGS_test_profiler_enabled) {
EXPECT_GT(new_tick_count, old_tick_count);
EXPECT_GT(interrupts_after, interrupts_before);
} else {
EXPECT_EQ(new_tick_count, old_tick_count);
EXPECT_EQ(interrupts_after, interrupts_before);
}
}
// Verifies that a callback is not receiving profile ticks.
void VerifyUnregistration(const int& tick_counter) {
// Sleep for a bit and check that tick counter is not making progress.
int old_tick_count = tick_counter;
Delay(kSleepInterval);
int new_tick_count = tick_counter;
EXPECT_EQ(old_tick_count, new_tick_count);
// If no callbacks, timer should be disabled.
if (GetCallbackCount() == 0) {
EXPECT_FALSE(IsTimerEnabled());
}
}
// Verifies that the timer is disabled. Expects the worker to be running.
void VerifyDisabled() {
// Check that the callback count is 0.
EXPECT_EQ(0, GetCallbackCount());
// Check that the timer is disabled.
EXPECT_FALSE(IsTimerEnabled());
// Verify that the ProfileHandler is not accumulating profile ticks.
uint64 interrupts_before = GetInterruptCount();
Delay(kSleepInterval);
uint64 interrupts_after = GetInterruptCount();
EXPECT_EQ(interrupts_before, interrupts_after);
}
// Registers a callback and waits for kTimerResetInterval for timers to get
// reset.
ProfileHandlerToken* RegisterCallback(void* callback_arg) {
ProfileHandlerToken* token = ProfileHandlerRegisterCallback(
TickCounter, callback_arg);
Delay(kTimerResetInterval);
return token;
}
// Unregisters a callback and waits for kTimerResetInterval for timers to get
// reset.
void UnregisterCallback(ProfileHandlerToken* token) {
ProfileHandlerUnregisterCallback(token);
Delay(kTimerResetInterval);
}
// Busy worker thread to accumulate cpu usage.
BusyThread* busy_worker_;
private:
// The tests to run
void RegisterUnregisterCallback();
void MultipleCallbacks();
void Reset();
void RegisterCallbackBeforeThread();
public:
#define RUN(test) do { \
printf("Running %s\n", #test); \
ProfileHandlerTest pht; \
pht.SetUp(); \
pht.test(); \
pht.TearDown(); \
} while (0)
static int RUN_ALL_TESTS() {
SetUpTestCase();
RUN(RegisterUnregisterCallback);
RUN(MultipleCallbacks);
RUN(Reset);
RUN(RegisterCallbackBeforeThread);
printf("Done\n");
return 0;
}
};
// Verifies ProfileHandlerRegisterCallback and
// ProfileHandlerUnregisterCallback.
TEST_F(ProfileHandlerTest, RegisterUnregisterCallback) {
int tick_count = 0;
ProfileHandlerToken* token = RegisterCallback(&tick_count);
VerifyRegistration(tick_count);
UnregisterCallback(token);
VerifyUnregistration(tick_count);
}
// Verifies that multiple callbacks can be registered.
TEST_F(ProfileHandlerTest, MultipleCallbacks) {
// Register first callback.
int first_tick_count = 0;
ProfileHandlerToken* token1 = RegisterCallback(&first_tick_count);
// Check that callback was registered correctly.
VerifyRegistration(first_tick_count);
EXPECT_EQ(1, GetCallbackCount());
// Register second callback.
int second_tick_count = 0;
ProfileHandlerToken* token2 = RegisterCallback(&second_tick_count);
// Check that callback was registered correctly.
VerifyRegistration(second_tick_count);
EXPECT_EQ(2, GetCallbackCount());
// Unregister first callback.
UnregisterCallback(token1);
VerifyUnregistration(first_tick_count);
EXPECT_EQ(1, GetCallbackCount());
// Verify that second callback is still registered.
VerifyRegistration(second_tick_count);
// Unregister second callback.
UnregisterCallback(token2);
VerifyUnregistration(second_tick_count);
EXPECT_EQ(0, GetCallbackCount());
// Verify that the timers is correctly disabled.
if (!linux_per_thread_timers_mode_) VerifyDisabled();
}
// Verifies ProfileHandlerReset
TEST_F(ProfileHandlerTest, Reset) {
// Verify that the profile timer interrupt is disabled.
if (!linux_per_thread_timers_mode_) VerifyDisabled();
int first_tick_count = 0;
RegisterCallback(&first_tick_count);
VerifyRegistration(first_tick_count);
EXPECT_EQ(1, GetCallbackCount());
// Register second callback.
int second_tick_count = 0;
RegisterCallback(&second_tick_count);
VerifyRegistration(second_tick_count);
EXPECT_EQ(2, GetCallbackCount());
// Reset the profile handler and verify that callback were correctly
// unregistered and the timer is disabled.
ProfileHandlerReset();
VerifyUnregistration(first_tick_count);
VerifyUnregistration(second_tick_count);
if (!linux_per_thread_timers_mode_) VerifyDisabled();
}
// Verifies that ProfileHandler correctly handles a case where a callback was
// registered before the second thread started.
TEST_F(ProfileHandlerTest, RegisterCallbackBeforeThread) {
// Stop the worker.
StopWorker();
// Unregister all existing callbacks and stop the timer.
ProfileHandlerReset();
EXPECT_EQ(0, GetCallbackCount());
VerifyDisabled();
// Start the worker.
StartWorker();
// Register a callback and check that profile ticks are being delivered and
// the timer is enabled.
int tick_count = 0;
RegisterCallback(&tick_count);
EXPECT_EQ(1, GetCallbackCount());
VerifyRegistration(tick_count);
EXPECT_EQ(FLAGS_test_profiler_enabled, linux_per_thread_timers_mode_ || IsTimerEnabled());
}
} // namespace
int main(int argc, char** argv) {
return ProfileHandlerTest::RUN_ALL_TESTS();
}
| Unknown |
3D | mcellteam/mcell | libs/gperftools/src/tests/low_level_alloc_unittest.cc | .cc | 6,617 | 198 | // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
/* Copyright (c) 2006, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// A test for low_level_alloc.cc
#include <stdio.h>
#include <map>
#include "base/low_level_alloc.h"
#include "base/logging.h"
#include <gperftools/malloc_hook.h>
using std::map;
// a block of memory obtained from the allocator
struct BlockDesc {
char *ptr; // pointer to memory
int len; // number of bytes
int fill; // filled with data starting with this
};
// Check that the pattern placed in the block d
// by RandomizeBlockDesc is still there.
static void CheckBlockDesc(const BlockDesc &d) {
for (int i = 0; i != d.len; i++) {
CHECK((d.ptr[i] & 0xff) == ((d.fill + i) & 0xff));
}
}
// Fill the block "*d" with a pattern
// starting with a random byte.
static void RandomizeBlockDesc(BlockDesc *d) {
d->fill = rand() & 0xff;
for (int i = 0; i != d->len; i++) {
d->ptr[i] = (d->fill + i) & 0xff;
}
}
// Use to indicate to the malloc hooks that
// this calls is from LowLevelAlloc.
static bool using_low_level_alloc = false;
// n times, toss a coin, and based on the outcome
// either allocate a new block or deallocate an old block.
// New blocks are placed in a map with a random key
// and initialized with RandomizeBlockDesc().
// If keys conflict, the older block is freed.
// Old blocks are always checked with CheckBlockDesc()
// before being freed. At the end of the run,
// all remaining allocated blocks are freed.
// If use_new_arena is true, use a fresh arena, and then delete it.
// If call_malloc_hook is true and user_arena is true,
// allocations and deallocations are reported via the MallocHook
// interface.
static void Test(bool use_new_arena, bool call_malloc_hook, int n) {
typedef map<int, BlockDesc> AllocMap;
AllocMap allocated;
AllocMap::iterator it;
BlockDesc block_desc;
int rnd;
LowLevelAlloc::Arena *arena = 0;
if (use_new_arena) {
int32 flags = call_malloc_hook? LowLevelAlloc::kCallMallocHook : 0;
arena = LowLevelAlloc::NewArena(flags, LowLevelAlloc::DefaultArena());
}
for (int i = 0; i != n; i++) {
if (i != 0 && i % 10000 == 0) {
printf(".");
fflush(stdout);
}
switch(rand() & 1) { // toss a coin
case 0: // coin came up heads: add a block
using_low_level_alloc = true;
block_desc.len = rand() & 0x3fff;
block_desc.ptr =
reinterpret_cast<char *>(
arena == 0
? LowLevelAlloc::Alloc(block_desc.len)
: LowLevelAlloc::AllocWithArena(block_desc.len, arena));
using_low_level_alloc = false;
RandomizeBlockDesc(&block_desc);
rnd = rand();
it = allocated.find(rnd);
if (it != allocated.end()) {
CheckBlockDesc(it->second);
using_low_level_alloc = true;
LowLevelAlloc::Free(it->second.ptr);
using_low_level_alloc = false;
it->second = block_desc;
} else {
allocated[rnd] = block_desc;
}
break;
case 1: // coin came up tails: remove a block
it = allocated.begin();
if (it != allocated.end()) {
CheckBlockDesc(it->second);
using_low_level_alloc = true;
LowLevelAlloc::Free(it->second.ptr);
using_low_level_alloc = false;
allocated.erase(it);
}
break;
}
}
// remove all remaniing blocks
while ((it = allocated.begin()) != allocated.end()) {
CheckBlockDesc(it->second);
using_low_level_alloc = true;
LowLevelAlloc::Free(it->second.ptr);
using_low_level_alloc = false;
allocated.erase(it);
}
if (use_new_arena) {
CHECK(LowLevelAlloc::DeleteArena(arena));
}
}
// used for counting allocates and frees
static int32 allocates;
static int32 frees;
// called on each alloc if kCallMallocHook specified
static void AllocHook(const void *p, size_t size) {
if (using_low_level_alloc) {
allocates++;
}
}
// called on each free if kCallMallocHook specified
static void FreeHook(const void *p) {
if (using_low_level_alloc) {
frees++;
}
}
int main(int argc, char *argv[]) {
// This is needed by maybe_threads_unittest.sh, which parses argv[0]
// to figure out what directory low_level_alloc_unittest is in.
if (argc != 1) {
fprintf(stderr, "USAGE: %s\n", argv[0]);
return 1;
}
CHECK(MallocHook::AddNewHook(&AllocHook));
CHECK(MallocHook::AddDeleteHook(&FreeHook));
CHECK_EQ(allocates, 0);
CHECK_EQ(frees, 0);
Test(false, false, 50000);
CHECK_NE(allocates, 0); // default arena calls hooks
CHECK_NE(frees, 0);
for (int i = 0; i != 16; i++) {
bool call_hooks = ((i & 1) == 1);
allocates = 0;
frees = 0;
Test(true, call_hooks, 15000);
if (call_hooks) {
CHECK_GT(allocates, 5000); // arena calls hooks
CHECK_GT(frees, 5000);
} else {
CHECK_EQ(allocates, 0); // arena doesn't call hooks
CHECK_EQ(frees, 0);
}
}
printf("\nPASS\n");
CHECK(MallocHook::RemoveNewHook(&AllocHook));
CHECK(MallocHook::RemoveDeleteHook(&FreeHook));
return 0;
}
| Unknown |
3D | mcellteam/mcell | libs/glm/mat2x4.hpp | .hpp | 233 | 10 | /// @ref core
/// @file glm/mat2x4.hpp
#pragma once
#include "./ext/matrix_double2x4.hpp"
#include "./ext/matrix_double2x4_precision.hpp"
#include "./ext/matrix_float2x4.hpp"
#include "./ext/matrix_float2x4_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/matrix.hpp | .hpp | 5,899 | 162 | /// @ref core
/// @file glm/matrix.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
///
/// @defgroup core_func_matrix Matrix functions
/// @ingroup core
///
/// Provides GLSL matrix functions.
///
/// Include <glm/matrix.hpp> to use these core features.
#pragma once
// Dependencies
#include "detail/qualifier.hpp"
#include "detail/setup.hpp"
#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"
namespace glm {
namespace detail
{
template<length_t C, length_t R, typename T, qualifier Q>
struct outerProduct_trait{};
template<typename T, qualifier Q>
struct outerProduct_trait<2, 2, T, Q>
{
typedef mat<2, 2, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<2, 3, T, Q>
{
typedef mat<3, 2, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<2, 4, T, Q>
{
typedef mat<4, 2, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<3, 2, T, Q>
{
typedef mat<2, 3, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<3, 3, T, Q>
{
typedef mat<3, 3, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<3, 4, T, Q>
{
typedef mat<4, 3, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<4, 2, T, Q>
{
typedef mat<2, 4, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<4, 3, T, Q>
{
typedef mat<3, 4, T, Q> type;
};
template<typename T, qualifier Q>
struct outerProduct_trait<4, 4, T, Q>
{
typedef mat<4, 4, T, Q> type;
};
}//namespace detail
/// @addtogroup core_func_matrix
/// @{
/// Multiply matrix x by matrix y component-wise, i.e.,
/// result[i][j] is the scalar product of x[i][j] and y[i][j].
///
/// @tparam C Integer between 1 and 4 included that qualify the number a column
/// @tparam R Integer between 1 and 4 included that qualify the number a row
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/matrixCompMult.xml">GLSL matrixCompMult man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL mat<C, R, T, Q> matrixCompMult(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y);
/// Treats the first parameter c as a column vector
/// and the second parameter r as a row vector
/// and does a linear algebraic matrix multiply c * r.
///
/// @tparam C Integer between 1 and 4 included that qualify the number a column
/// @tparam R Integer between 1 and 4 included that qualify the number a row
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL typename detail::outerProduct_trait<C, R, T, Q>::type outerProduct(vec<C, T, Q> const& c, vec<R, T, Q> const& r);
/// Returns the transposed matrix of x
///
/// @tparam C Integer between 1 and 4 included that qualify the number a column
/// @tparam R Integer between 1 and 4 included that qualify the number a row
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/transpose.xml">GLSL transpose man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL typename mat<C, R, T, Q>::transpose_type transpose(mat<C, R, T, Q> const& x);
/// Return the determinant of a squared matrix.
///
/// @tparam C Integer between 1 and 4 included that qualify the number a column
/// @tparam R Integer between 1 and 4 included that qualify the number a row
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL T determinant(mat<C, R, T, Q> const& m);
/// Return the inverse of a squared matrix.
///
/// @tparam C Integer between 1 and 4 included that qualify the number a column
/// @tparam R Integer between 1 and 4 included that qualify the number a row
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL mat<C, R, T, Q> inverse(mat<C, R, T, Q> const& m);
/// @}
}//namespace glm
#include "detail/func_matrix.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/geometric.hpp | .hpp | 5,467 | 117 | /// @ref core
/// @file glm/geometric.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
///
/// @defgroup core_func_geometric Geometric functions
/// @ingroup core
///
/// These operate on vectors as vectors, not component-wise.
///
/// Include <glm/geometric.hpp> to use these core features.
#pragma once
#include "detail/type_vec3.hpp"
namespace glm
{
/// @addtogroup core_func_geometric
/// @{
/// Returns the length of x, i.e., sqrt(x * x).
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T length(vec<L, T, Q> const& x);
/// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1);
/// Returns the dot product of x and y, i.e., result = x * y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the cross product of x and y.
///
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y);
/// Returns a vector in the same direction as x but with length of 1.
/// According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefined and generate an error.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> normalize(vec<L, T, Q> const& x);
/// If dot(Nref, I) < 0.0, return N, otherwise, return -N.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> faceforward(
vec<L, T, Q> const& N,
vec<L, T, Q> const& I,
vec<L, T, Q> const& Nref);
/// For the incident vector I and surface orientation N,
/// returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> reflect(
vec<L, T, Q> const& I,
vec<L, T, Q> const& N);
/// For the incident vector I and surface normal N,
/// and the ratio of indices of refraction eta,
/// return the refraction vector.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> refract(
vec<L, T, Q> const& I,
vec<L, T, Q> const& N,
T eta);
/// @}
}//namespace glm
#include "detail/func_geometric.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/vec3.hpp | .hpp | 459 | 15 | /// @ref core
/// @file glm/vec3.hpp
#pragma once
#include "./ext/vector_bool3.hpp"
#include "./ext/vector_bool3_precision.hpp"
#include "./ext/vector_float3.hpp"
#include "./ext/vector_float3_precision.hpp"
#include "./ext/vector_double3.hpp"
#include "./ext/vector_double3_precision.hpp"
#include "./ext/vector_int3.hpp"
#include "./ext/vector_int3_precision.hpp"
#include "./ext/vector_uint3.hpp"
#include "./ext/vector_uint3_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/common.hpp | .hpp | 27,944 | 534 | /// @ref core
/// @file glm/common.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
///
/// @defgroup core_func_common Common functions
/// @ingroup core
///
/// Provides GLSL common functions
///
/// These all operate component-wise. The description is per component.
///
/// Include <glm/common.hpp> to use these core features.
#pragma once
#include "detail/qualifier.hpp"
#include "detail/_fixes.hpp"
namespace glm
{
/// @addtogroup core_func_common
/// @{
/// Returns x if x >= 0; otherwise, it returns -x.
///
/// @tparam genType floating-point or signed integer; scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType abs(genType x);
/// Returns x if x >= 0; otherwise, it returns -x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> abs(vec<L, T, Q> const& x);
/// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> sign(vec<L, T, Q> const& x);
/// Returns a value equal to the nearest integer that is less then or equal to x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floor.xml">GLSL floor man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> floor(vec<L, T, Q> const& x);
/// Returns a value equal to the nearest integer to x
/// whose absolute value is not larger than the absolute value of x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/trunc.xml">GLSL trunc man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> trunc(vec<L, T, Q> const& x);
/// Returns a value equal to the nearest integer to x.
/// The fraction 0.5 will round in a direction chosen by the
/// implementation, presumably the direction that is fastest.
/// This includes the possibility that round(x) returns the
/// same value as roundEven(x) for all values of x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> round(vec<L, T, Q> const& x);
/// Returns a value equal to the nearest integer to x.
/// A fractional part of 0.5 will round toward the nearest even
/// integer. (Both 3.5 and 4.5 for x will return 4.0.)
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/roundEven.xml">GLSL roundEven man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
/// @see <a href="http://developer.amd.com/documentation/articles/pages/New-Round-to-Even-Technique.aspx">New round to even technique</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> roundEven(vec<L, T, Q> const& x);
/// Returns a value equal to the nearest integer
/// that is greater than or equal to x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ceil.xml">GLSL ceil man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> ceil(vec<L, T, Q> const& x);
/// Return x - floor(x).
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL genType fract(genType x);
/// Return x - floor(x).
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fract(vec<L, T, Q> const& x);
template<typename genType>
GLM_FUNC_DECL genType mod(genType x, genType y);
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> mod(vec<L, T, Q> const& x, T y);
/// Modulus. Returns x - y * floor(x / y)
/// for each component in x using the floating point value y.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types, include glm/gtc/integer for integer scalar types support
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> mod(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the fractional part of x and sets i to the integer
/// part (as a whole number floating point value). Both the
/// return value and the output parameter will have the same
/// sign as x.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml">GLSL modf man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL genType modf(genType x, genType& i);
/// Returns y if y < x; otherwise, it returns x.
///
/// @tparam genType Floating-point or integer; scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType min(genType x, genType y);
/// Returns y if y < x; otherwise, it returns x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> min(vec<L, T, Q> const& x, T y);
/// Returns y if y < x; otherwise, it returns x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> min(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns y if x < y; otherwise, it returns x.
///
/// @tparam genType Floating-point or integer; scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType max(genType x, genType y);
/// Returns y if x < y; otherwise, it returns x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> max(vec<L, T, Q> const& x, T y);
/// Returns y if x < y; otherwise, it returns x.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> max(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns min(max(x, minVal), maxVal) for each component in x
/// using the floating-point values minVal and maxVal.
///
/// @tparam genType Floating-point or integer; scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL GLM_CONSTEXPR genType clamp(genType x, genType minVal, genType maxVal);
/// Returns min(max(x, minVal), maxVal) for each component in x
/// using the floating-point values minVal and maxVal.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> clamp(vec<L, T, Q> const& x, T minVal, T maxVal);
/// Returns min(max(x, minVal), maxVal) for each component in x
/// using the floating-point values minVal and maxVal.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> clamp(vec<L, T, Q> const& x, vec<L, T, Q> const& minVal, vec<L, T, Q> const& maxVal);
/// If genTypeU is a floating scalar or vector:
/// Returns x * (1.0 - a) + y * a, i.e., the linear blend of
/// x and y using the floating-point value a.
/// The value for a is not restricted to the range [0, 1].
///
/// If genTypeU is a boolean scalar or vector:
/// Selects which vector each returned component comes
/// from. For a component of 'a' that is false, the
/// corresponding component of 'x' is returned. For a
/// component of 'a' that is true, the corresponding
/// component of 'y' is returned. Components of 'x' and 'y' that
/// are not selected are allowed to be invalid floating point
/// values and will have no effect on the results. Thus, this
/// provides different functionality than
/// genType mix(genType x, genType y, genType(a))
/// where a is a Boolean vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mix.xml">GLSL mix man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
///
/// @param[in] x Value to interpolate.
/// @param[in] y Value to interpolate.
/// @param[in] a Interpolant.
///
/// @tparam genTypeT Floating point scalar or vector.
/// @tparam genTypeU Floating point or boolean scalar or vector. It can't be a vector if it is the length of genTypeT.
///
/// @code
/// #include <glm/glm.hpp>
/// ...
/// float a;
/// bool b;
/// glm::dvec3 e;
/// glm::dvec3 f;
/// glm::vec4 g;
/// glm::vec4 h;
/// ...
/// glm::vec4 r = glm::mix(g, h, a); // Interpolate with a floating-point scalar two vectors.
/// glm::vec4 s = glm::mix(g, h, b); // Returns g or h;
/// glm::dvec3 t = glm::mix(e, f, a); // Types of the third parameter is not required to match with the first and the second.
/// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter.
/// @endcode
template<typename genTypeT, typename genTypeU>
GLM_FUNC_DECL genTypeT mix(genTypeT x, genTypeT y, genTypeU a);
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> mix(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, U, Q> const& a);
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> mix(vec<L, T, Q> const& x, vec<L, T, Q> const& y, U a);
/// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL genType step(genType edge, genType x);
/// Returns 0.0 if x < edge, otherwise it returns 1.0.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> step(T edge, vec<L, T, Q> const& x);
/// Returns 0.0 if x < edge, otherwise it returns 1.0.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> step(vec<L, T, Q> const& edge, vec<L, T, Q> const& x);
/// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and
/// performs smooth Hermite interpolation between 0 and 1
/// when edge0 < x < edge1. This is useful in cases where
/// you would want a threshold function with a smooth
/// transition. This is equivalent to:
/// genType t;
/// t = clamp ((x - edge0) / (edge1 - edge0), 0, 1);
/// return t * t * (3 - 2 * t);
/// Results are undefined if edge0 >= edge1.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/smoothstep.xml">GLSL smoothstep man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL genType smoothstep(genType edge0, genType edge1, genType x);
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> smoothstep(T edge0, T edge1, vec<L, T, Q> const& x);
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> smoothstep(vec<L, T, Q> const& edge0, vec<L, T, Q> const& edge1, vec<L, T, Q> const& x);
/// Returns true if x holds a NaN (not a number)
/// representation in the underlying implementation's set of
/// floating point representations. Returns false otherwise,
/// including for implementations with no NaN
/// representations.
///
/// /!\ When using compiler fast math, this function may fail.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isnan.xml">GLSL isnan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, bool, Q> isnan(vec<L, T, Q> const& x);
/// Returns true if x holds a positive infinity or negative
/// infinity representation in the underlying implementation's
/// set of floating point representations. Returns false
/// otherwise, including for implementations with no infinity
/// representations.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isinf.xml">GLSL isinf man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, bool, Q> isinf(vec<L, T, Q> const& x);
/// Returns a signed integer value representing
/// the encoding of a floating-point value. The floating-point
/// value's bit-level representation is preserved.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
GLM_FUNC_DECL int floatBitsToInt(float const& v);
/// Returns a signed integer value representing
/// the encoding of a floating-point value. The floatingpoint
/// value's bit-level representation is preserved.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL vec<L, int, Q> floatBitsToInt(vec<L, float, Q> const& v);
/// Returns a unsigned integer value representing
/// the encoding of a floating-point value. The floatingpoint
/// value's bit-level representation is preserved.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
GLM_FUNC_DECL uint floatBitsToUint(float const& v);
/// Returns a unsigned integer value representing
/// the encoding of a floating-point value. The floatingpoint
/// value's bit-level representation is preserved.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL vec<L, uint, Q> floatBitsToUint(vec<L, float, Q> const& v);
/// Returns a floating-point value corresponding to a signed
/// integer encoding of a floating-point value.
/// If an inf or NaN is passed in, it will not signal, and the
/// resulting floating point value is unspecified. Otherwise,
/// the bit-level representation is preserved.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
GLM_FUNC_DECL float intBitsToFloat(int const& v);
/// Returns a floating-point value corresponding to a signed
/// integer encoding of a floating-point value.
/// If an inf or NaN is passed in, it will not signal, and the
/// resulting floating point value is unspecified. Otherwise,
/// the bit-level representation is preserved.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL vec<L, float, Q> intBitsToFloat(vec<L, int, Q> const& v);
/// Returns a floating-point value corresponding to a
/// unsigned integer encoding of a floating-point value.
/// If an inf or NaN is passed in, it will not signal, and the
/// resulting floating point value is unspecified. Otherwise,
/// the bit-level representation is preserved.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
GLM_FUNC_DECL float uintBitsToFloat(uint const& v);
/// Returns a floating-point value corresponding to a
/// unsigned integer encoding of a floating-point value.
/// If an inf or NaN is passed in, it will not signal, and the
/// resulting floating point value is unspecified. Otherwise,
/// the bit-level representation is preserved.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL vec<L, float, Q> uintBitsToFloat(vec<L, uint, Q> const& v);
/// Computes and returns a * b + c.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fma.xml">GLSL fma man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL genType fma(genType const& a, genType const& b, genType const& c);
/// Splits x into a floating-point significand in the range
/// [0.5, 1.0) and an integral exponent of two, such that:
/// x = significand * exp(2, exponent)
///
/// The significand is returned by the function and the
/// exponent is returned in the parameter exp. For a
/// floating-point value of zero, the significant and exponent
/// are both zero. For a floating-point value that is an
/// infinity or is not a number, the results are undefined.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType frexp(genType const& x, genIType& exp);
/// Builds a floating-point number from x and the
/// corresponding integral exponent of two in exp, returning:
/// significand * exp(2, exponent)
///
/// If this product is too large to be represented in the
/// floating-point type, the result is undefined.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp);
/// @}
}//namespace glm
#include "detail/func_common.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat3x4.hpp | .hpp | 231 | 9 | /// @ref core
/// @file glm/mat3x4.hpp
#pragma once
#include "./ext/matrix_double3x4.hpp"
#include "./ext/matrix_double3x4_precision.hpp"
#include "./ext/matrix_float3x4.hpp"
#include "./ext/matrix_float3x4_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/fwd.hpp | .hpp | 28,364 | 819 | #pragma once
#include "detail/qualifier.hpp"
namespace glm
{
#if GLM_HAS_EXTENDED_INTEGER_TYPE
typedef std::int8_t int8;
typedef std::int16_t int16;
typedef std::int32_t int32;
typedef std::int64_t int64;
typedef std::uint8_t uint8;
typedef std::uint16_t uint16;
typedef std::uint32_t uint32;
typedef std::uint64_t uint64;
#else
typedef char int8;
typedef short int16;
typedef int int32;
typedef detail::int64 int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef detail::uint64 uint64;
#endif
// Scalar int
typedef int8 lowp_i8;
typedef int8 mediump_i8;
typedef int8 highp_i8;
typedef int8 i8;
typedef int8 lowp_int8;
typedef int8 mediump_int8;
typedef int8 highp_int8;
typedef int8 lowp_int8_t;
typedef int8 mediump_int8_t;
typedef int8 highp_int8_t;
typedef int8 int8_t;
typedef int16 lowp_i16;
typedef int16 mediump_i16;
typedef int16 highp_i16;
typedef int16 i16;
typedef int16 lowp_int16;
typedef int16 mediump_int16;
typedef int16 highp_int16;
typedef int16 lowp_int16_t;
typedef int16 mediump_int16_t;
typedef int16 highp_int16_t;
typedef int16 int16_t;
typedef int32 lowp_i32;
typedef int32 mediump_i32;
typedef int32 highp_i32;
typedef int32 i32;
typedef int32 lowp_int32;
typedef int32 mediump_int32;
typedef int32 highp_int32;
typedef int32 lowp_int32_t;
typedef int32 mediump_int32_t;
typedef int32 highp_int32_t;
typedef int32 int32_t;
typedef int64 lowp_i64;
typedef int64 mediump_i64;
typedef int64 highp_i64;
typedef int64 i64;
typedef int64 lowp_int64;
typedef int64 mediump_int64;
typedef int64 highp_int64;
typedef int64 lowp_int64_t;
typedef int64 mediump_int64_t;
typedef int64 highp_int64_t;
typedef int64 int64_t;
// Scalar uint
typedef uint8 lowp_u8;
typedef uint8 mediump_u8;
typedef uint8 highp_u8;
typedef uint8 u8;
typedef uint8 lowp_uint8;
typedef uint8 mediump_uint8;
typedef uint8 highp_uint8;
typedef uint8 lowp_uint8_t;
typedef uint8 mediump_uint8_t;
typedef uint8 highp_uint8_t;
typedef uint8 uint8_t;
typedef uint16 lowp_u16;
typedef uint16 mediump_u16;
typedef uint16 highp_u16;
typedef uint16 u16;
typedef uint16 lowp_uint16;
typedef uint16 mediump_uint16;
typedef uint16 highp_uint16;
typedef uint16 lowp_uint16_t;
typedef uint16 mediump_uint16_t;
typedef uint16 highp_uint16_t;
typedef uint16 uint16_t;
typedef uint32 lowp_u32;
typedef uint32 mediump_u32;
typedef uint32 highp_u32;
typedef uint32 u32;
typedef uint32 lowp_uint32;
typedef uint32 mediump_uint32;
typedef uint32 highp_uint32;
typedef uint32 lowp_uint32_t;
typedef uint32 mediump_uint32_t;
typedef uint32 highp_uint32_t;
typedef uint32 uint32_t;
typedef uint64 lowp_u64;
typedef uint64 mediump_u64;
typedef uint64 highp_u64;
typedef uint64 u64;
typedef uint64 lowp_uint64;
typedef uint64 mediump_uint64;
typedef uint64 highp_uint64;
typedef uint64 lowp_uint64_t;
typedef uint64 mediump_uint64_t;
typedef uint64 highp_uint64_t;
typedef uint64 uint64_t;
// Scalar float
typedef float lowp_f32;
typedef float mediump_f32;
typedef float highp_f32;
typedef float f32;
typedef float lowp_float32;
typedef float mediump_float32;
typedef float highp_float32;
typedef float float32;
typedef float lowp_float32_t;
typedef float mediump_float32_t;
typedef float highp_float32_t;
typedef float float32_t;
typedef double lowp_f64;
typedef double mediump_f64;
typedef double highp_f64;
typedef double f64;
typedef double lowp_float64;
typedef double mediump_float64;
typedef double highp_float64;
typedef double float64;
typedef double lowp_float64_t;
typedef double mediump_float64_t;
typedef double highp_float64_t;
typedef double float64_t;
// Vector bool
typedef vec<1, bool, lowp> lowp_bvec1;
typedef vec<2, bool, lowp> lowp_bvec2;
typedef vec<3, bool, lowp> lowp_bvec3;
typedef vec<4, bool, lowp> lowp_bvec4;
typedef vec<1, bool, mediump> mediump_bvec1;
typedef vec<2, bool, mediump> mediump_bvec2;
typedef vec<3, bool, mediump> mediump_bvec3;
typedef vec<4, bool, mediump> mediump_bvec4;
typedef vec<1, bool, highp> highp_bvec1;
typedef vec<2, bool, highp> highp_bvec2;
typedef vec<3, bool, highp> highp_bvec3;
typedef vec<4, bool, highp> highp_bvec4;
typedef vec<1, bool, defaultp> bvec1;
typedef vec<2, bool, defaultp> bvec2;
typedef vec<3, bool, defaultp> bvec3;
typedef vec<4, bool, defaultp> bvec4;
// Vector int
typedef vec<1, i32, lowp> lowp_ivec1;
typedef vec<2, i32, lowp> lowp_ivec2;
typedef vec<3, i32, lowp> lowp_ivec3;
typedef vec<4, i32, lowp> lowp_ivec4;
typedef vec<1, i32, mediump> mediump_ivec1;
typedef vec<2, i32, mediump> mediump_ivec2;
typedef vec<3, i32, mediump> mediump_ivec3;
typedef vec<4, i32, mediump> mediump_ivec4;
typedef vec<1, i32, highp> highp_ivec1;
typedef vec<2, i32, highp> highp_ivec2;
typedef vec<3, i32, highp> highp_ivec3;
typedef vec<4, i32, highp> highp_ivec4;
typedef vec<1, i32, defaultp> ivec1;
typedef vec<2, i32, defaultp> ivec2;
typedef vec<3, i32, defaultp> ivec3;
typedef vec<4, i32, defaultp> ivec4;
typedef vec<1, i8, lowp> lowp_i8vec1;
typedef vec<2, i8, lowp> lowp_i8vec2;
typedef vec<3, i8, lowp> lowp_i8vec3;
typedef vec<4, i8, lowp> lowp_i8vec4;
typedef vec<1, i8, mediump> mediump_i8vec1;
typedef vec<2, i8, mediump> mediump_i8vec2;
typedef vec<3, i8, mediump> mediump_i8vec3;
typedef vec<4, i8, mediump> mediump_i8vec4;
typedef vec<1, i8, highp> highp_i8vec1;
typedef vec<2, i8, highp> highp_i8vec2;
typedef vec<3, i8, highp> highp_i8vec3;
typedef vec<4, i8, highp> highp_i8vec4;
typedef vec<1, i8, defaultp> i8vec1;
typedef vec<2, i8, defaultp> i8vec2;
typedef vec<3, i8, defaultp> i8vec3;
typedef vec<4, i8, defaultp> i8vec4;
typedef vec<1, i16, lowp> lowp_i16vec1;
typedef vec<2, i16, lowp> lowp_i16vec2;
typedef vec<3, i16, lowp> lowp_i16vec3;
typedef vec<4, i16, lowp> lowp_i16vec4;
typedef vec<1, i16, mediump> mediump_i16vec1;
typedef vec<2, i16, mediump> mediump_i16vec2;
typedef vec<3, i16, mediump> mediump_i16vec3;
typedef vec<4, i16, mediump> mediump_i16vec4;
typedef vec<1, i16, highp> highp_i16vec1;
typedef vec<2, i16, highp> highp_i16vec2;
typedef vec<3, i16, highp> highp_i16vec3;
typedef vec<4, i16, highp> highp_i16vec4;
typedef vec<1, i16, defaultp> i16vec1;
typedef vec<2, i16, defaultp> i16vec2;
typedef vec<3, i16, defaultp> i16vec3;
typedef vec<4, i16, defaultp> i16vec4;
typedef vec<1, i32, lowp> lowp_i32vec1;
typedef vec<2, i32, lowp> lowp_i32vec2;
typedef vec<3, i32, lowp> lowp_i32vec3;
typedef vec<4, i32, lowp> lowp_i32vec4;
typedef vec<1, i32, mediump> mediump_i32vec1;
typedef vec<2, i32, mediump> mediump_i32vec2;
typedef vec<3, i32, mediump> mediump_i32vec3;
typedef vec<4, i32, mediump> mediump_i32vec4;
typedef vec<1, i32, highp> highp_i32vec1;
typedef vec<2, i32, highp> highp_i32vec2;
typedef vec<3, i32, highp> highp_i32vec3;
typedef vec<4, i32, highp> highp_i32vec4;
typedef vec<1, i32, defaultp> i32vec1;
typedef vec<2, i32, defaultp> i32vec2;
typedef vec<3, i32, defaultp> i32vec3;
typedef vec<4, i32, defaultp> i32vec4;
typedef vec<1, i64, lowp> lowp_i64vec1;
typedef vec<2, i64, lowp> lowp_i64vec2;
typedef vec<3, i64, lowp> lowp_i64vec3;
typedef vec<4, i64, lowp> lowp_i64vec4;
typedef vec<1, i64, mediump> mediump_i64vec1;
typedef vec<2, i64, mediump> mediump_i64vec2;
typedef vec<3, i64, mediump> mediump_i64vec3;
typedef vec<4, i64, mediump> mediump_i64vec4;
typedef vec<1, i64, highp> highp_i64vec1;
typedef vec<2, i64, highp> highp_i64vec2;
typedef vec<3, i64, highp> highp_i64vec3;
typedef vec<4, i64, highp> highp_i64vec4;
typedef vec<1, i64, defaultp> i64vec1;
typedef vec<2, i64, defaultp> i64vec2;
typedef vec<3, i64, defaultp> i64vec3;
typedef vec<4, i64, defaultp> i64vec4;
// Vector uint
typedef vec<1, u32, lowp> lowp_uvec1;
typedef vec<2, u32, lowp> lowp_uvec2;
typedef vec<3, u32, lowp> lowp_uvec3;
typedef vec<4, u32, lowp> lowp_uvec4;
typedef vec<1, u32, mediump> mediump_uvec1;
typedef vec<2, u32, mediump> mediump_uvec2;
typedef vec<3, u32, mediump> mediump_uvec3;
typedef vec<4, u32, mediump> mediump_uvec4;
typedef vec<1, u32, highp> highp_uvec1;
typedef vec<2, u32, highp> highp_uvec2;
typedef vec<3, u32, highp> highp_uvec3;
typedef vec<4, u32, highp> highp_uvec4;
typedef vec<1, u32, defaultp> uvec1;
typedef vec<2, u32, defaultp> uvec2;
typedef vec<3, u32, defaultp> uvec3;
typedef vec<4, u32, defaultp> uvec4;
typedef vec<1, u8, lowp> lowp_u8vec1;
typedef vec<2, u8, lowp> lowp_u8vec2;
typedef vec<3, u8, lowp> lowp_u8vec3;
typedef vec<4, u8, lowp> lowp_u8vec4;
typedef vec<1, u8, mediump> mediump_u8vec1;
typedef vec<2, u8, mediump> mediump_u8vec2;
typedef vec<3, u8, mediump> mediump_u8vec3;
typedef vec<4, u8, mediump> mediump_u8vec4;
typedef vec<1, u8, highp> highp_u8vec1;
typedef vec<2, u8, highp> highp_u8vec2;
typedef vec<3, u8, highp> highp_u8vec3;
typedef vec<4, u8, highp> highp_u8vec4;
typedef vec<1, u8, defaultp> u8vec1;
typedef vec<2, u8, defaultp> u8vec2;
typedef vec<3, u8, defaultp> u8vec3;
typedef vec<4, u8, defaultp> u8vec4;
typedef vec<1, u16, lowp> lowp_u16vec1;
typedef vec<2, u16, lowp> lowp_u16vec2;
typedef vec<3, u16, lowp> lowp_u16vec3;
typedef vec<4, u16, lowp> lowp_u16vec4;
typedef vec<1, u16, mediump> mediump_u16vec1;
typedef vec<2, u16, mediump> mediump_u16vec2;
typedef vec<3, u16, mediump> mediump_u16vec3;
typedef vec<4, u16, mediump> mediump_u16vec4;
typedef vec<1, u16, highp> highp_u16vec1;
typedef vec<2, u16, highp> highp_u16vec2;
typedef vec<3, u16, highp> highp_u16vec3;
typedef vec<4, u16, highp> highp_u16vec4;
typedef vec<1, u16, defaultp> u16vec1;
typedef vec<2, u16, defaultp> u16vec2;
typedef vec<3, u16, defaultp> u16vec3;
typedef vec<4, u16, defaultp> u16vec4;
typedef vec<1, u32, lowp> lowp_u32vec1;
typedef vec<2, u32, lowp> lowp_u32vec2;
typedef vec<3, u32, lowp> lowp_u32vec3;
typedef vec<4, u32, lowp> lowp_u32vec4;
typedef vec<1, u32, mediump> mediump_u32vec1;
typedef vec<2, u32, mediump> mediump_u32vec2;
typedef vec<3, u32, mediump> mediump_u32vec3;
typedef vec<4, u32, mediump> mediump_u32vec4;
typedef vec<1, u32, highp> highp_u32vec1;
typedef vec<2, u32, highp> highp_u32vec2;
typedef vec<3, u32, highp> highp_u32vec3;
typedef vec<4, u32, highp> highp_u32vec4;
typedef vec<1, u32, defaultp> u32vec1;
typedef vec<2, u32, defaultp> u32vec2;
typedef vec<3, u32, defaultp> u32vec3;
typedef vec<4, u32, defaultp> u32vec4;
typedef vec<1, u64, lowp> lowp_u64vec1;
typedef vec<2, u64, lowp> lowp_u64vec2;
typedef vec<3, u64, lowp> lowp_u64vec3;
typedef vec<4, u64, lowp> lowp_u64vec4;
typedef vec<1, u64, mediump> mediump_u64vec1;
typedef vec<2, u64, mediump> mediump_u64vec2;
typedef vec<3, u64, mediump> mediump_u64vec3;
typedef vec<4, u64, mediump> mediump_u64vec4;
typedef vec<1, u64, highp> highp_u64vec1;
typedef vec<2, u64, highp> highp_u64vec2;
typedef vec<3, u64, highp> highp_u64vec3;
typedef vec<4, u64, highp> highp_u64vec4;
typedef vec<1, u64, defaultp> u64vec1;
typedef vec<2, u64, defaultp> u64vec2;
typedef vec<3, u64, defaultp> u64vec3;
typedef vec<4, u64, defaultp> u64vec4;
// Vector float
typedef vec<1, float, lowp> lowp_vec1;
typedef vec<2, float, lowp> lowp_vec2;
typedef vec<3, float, lowp> lowp_vec3;
typedef vec<4, float, lowp> lowp_vec4;
typedef vec<1, float, mediump> mediump_vec1;
typedef vec<2, float, mediump> mediump_vec2;
typedef vec<3, float, mediump> mediump_vec3;
typedef vec<4, float, mediump> mediump_vec4;
typedef vec<1, float, highp> highp_vec1;
typedef vec<2, float, highp> highp_vec2;
typedef vec<3, float, highp> highp_vec3;
typedef vec<4, float, highp> highp_vec4;
typedef vec<1, float, defaultp> vec1;
typedef vec<2, float, defaultp> vec2;
typedef vec<3, float, defaultp> vec3;
typedef vec<4, float, defaultp> vec4;
typedef vec<1, float, lowp> lowp_fvec1;
typedef vec<2, float, lowp> lowp_fvec2;
typedef vec<3, float, lowp> lowp_fvec3;
typedef vec<4, float, lowp> lowp_fvec4;
typedef vec<1, float, mediump> mediump_fvec1;
typedef vec<2, float, mediump> mediump_fvec2;
typedef vec<3, float, mediump> mediump_fvec3;
typedef vec<4, float, mediump> mediump_fvec4;
typedef vec<1, float, highp> highp_fvec1;
typedef vec<2, float, highp> highp_fvec2;
typedef vec<3, float, highp> highp_fvec3;
typedef vec<4, float, highp> highp_fvec4;
typedef vec<1, f32, defaultp> fvec1;
typedef vec<2, f32, defaultp> fvec2;
typedef vec<3, f32, defaultp> fvec3;
typedef vec<4, f32, defaultp> fvec4;
typedef vec<1, f32, lowp> lowp_f32vec1;
typedef vec<2, f32, lowp> lowp_f32vec2;
typedef vec<3, f32, lowp> lowp_f32vec3;
typedef vec<4, f32, lowp> lowp_f32vec4;
typedef vec<1, f32, mediump> mediump_f32vec1;
typedef vec<2, f32, mediump> mediump_f32vec2;
typedef vec<3, f32, mediump> mediump_f32vec3;
typedef vec<4, f32, mediump> mediump_f32vec4;
typedef vec<1, f32, highp> highp_f32vec1;
typedef vec<2, f32, highp> highp_f32vec2;
typedef vec<3, f32, highp> highp_f32vec3;
typedef vec<4, f32, highp> highp_f32vec4;
typedef vec<1, f32, defaultp> f32vec1;
typedef vec<2, f32, defaultp> f32vec2;
typedef vec<3, f32, defaultp> f32vec3;
typedef vec<4, f32, defaultp> f32vec4;
typedef vec<1, f64, lowp> lowp_dvec1;
typedef vec<2, f64, lowp> lowp_dvec2;
typedef vec<3, f64, lowp> lowp_dvec3;
typedef vec<4, f64, lowp> lowp_dvec4;
typedef vec<1, f64, mediump> mediump_dvec1;
typedef vec<2, f64, mediump> mediump_dvec2;
typedef vec<3, f64, mediump> mediump_dvec3;
typedef vec<4, f64, mediump> mediump_dvec4;
typedef vec<1, f64, highp> highp_dvec1;
typedef vec<2, f64, highp> highp_dvec2;
typedef vec<3, f64, highp> highp_dvec3;
typedef vec<4, f64, highp> highp_dvec4;
typedef vec<1, f64, defaultp> dvec1;
typedef vec<2, f64, defaultp> dvec2;
typedef vec<3, f64, defaultp> dvec3;
typedef vec<4, f64, defaultp> dvec4;
typedef vec<1, f64, lowp> lowp_f64vec1;
typedef vec<2, f64, lowp> lowp_f64vec2;
typedef vec<3, f64, lowp> lowp_f64vec3;
typedef vec<4, f64, lowp> lowp_f64vec4;
typedef vec<1, f64, mediump> mediump_f64vec1;
typedef vec<2, f64, mediump> mediump_f64vec2;
typedef vec<3, f64, mediump> mediump_f64vec3;
typedef vec<4, f64, mediump> mediump_f64vec4;
typedef vec<1, f64, highp> highp_f64vec1;
typedef vec<2, f64, highp> highp_f64vec2;
typedef vec<3, f64, highp> highp_f64vec3;
typedef vec<4, f64, highp> highp_f64vec4;
typedef vec<1, f64, defaultp> f64vec1;
typedef vec<2, f64, defaultp> f64vec2;
typedef vec<3, f64, defaultp> f64vec3;
typedef vec<4, f64, defaultp> f64vec4;
// Matrix NxN
typedef mat<2, 2, f32, lowp> lowp_mat2;
typedef mat<3, 3, f32, lowp> lowp_mat3;
typedef mat<4, 4, f32, lowp> lowp_mat4;
typedef mat<2, 2, f32, mediump> mediump_mat2;
typedef mat<3, 3, f32, mediump> mediump_mat3;
typedef mat<4, 4, f32, mediump> mediump_mat4;
typedef mat<2, 2, f32, highp> highp_mat2;
typedef mat<3, 3, f32, highp> highp_mat3;
typedef mat<4, 4, f32, highp> highp_mat4;
typedef mat<2, 2, f32, defaultp> mat2;
typedef mat<3, 3, f32, defaultp> mat3;
typedef mat<4, 4, f32, defaultp> mat4;
typedef mat<2, 2, f32, lowp> lowp_fmat2;
typedef mat<3, 3, f32, lowp> lowp_fmat3;
typedef mat<4, 4, f32, lowp> lowp_fmat4;
typedef mat<2, 2, f32, mediump> mediump_fmat2;
typedef mat<3, 3, f32, mediump> mediump_fmat3;
typedef mat<4, 4, f32, mediump> mediump_fmat4;
typedef mat<2, 2, f32, highp> highp_fmat2;
typedef mat<3, 3, f32, highp> highp_fmat3;
typedef mat<4, 4, f32, highp> highp_fmat4;
typedef mat<2, 2, f32, defaultp> fmat2;
typedef mat<3, 3, f32, defaultp> fmat3;
typedef mat<4, 4, f32, defaultp> fmat4;
typedef mat<2, 2, f32, lowp> lowp_f32mat2;
typedef mat<3, 3, f32, lowp> lowp_f32mat3;
typedef mat<4, 4, f32, lowp> lowp_f32mat4;
typedef mat<2, 2, f32, mediump> mediump_f32mat2;
typedef mat<3, 3, f32, mediump> mediump_f32mat3;
typedef mat<4, 4, f32, mediump> mediump_f32mat4;
typedef mat<2, 2, f32, highp> highp_f32mat2;
typedef mat<3, 3, f32, highp> highp_f32mat3;
typedef mat<4, 4, f32, highp> highp_f32mat4;
typedef mat<2, 2, f32, defaultp> f32mat2;
typedef mat<3, 3, f32, defaultp> f32mat3;
typedef mat<4, 4, f32, defaultp> f32mat4;
typedef mat<2, 2, f64, lowp> lowp_dmat2;
typedef mat<3, 3, f64, lowp> lowp_dmat3;
typedef mat<4, 4, f64, lowp> lowp_dmat4;
typedef mat<2, 2, f64, mediump> mediump_dmat2;
typedef mat<3, 3, f64, mediump> mediump_dmat3;
typedef mat<4, 4, f64, mediump> mediump_dmat4;
typedef mat<2, 2, f64, highp> highp_dmat2;
typedef mat<3, 3, f64, highp> highp_dmat3;
typedef mat<4, 4, f64, highp> highp_dmat4;
typedef mat<2, 2, f64, defaultp> dmat2;
typedef mat<3, 3, f64, defaultp> dmat3;
typedef mat<4, 4, f64, defaultp> dmat4;
typedef mat<2, 2, f64, lowp> lowp_f64mat2;
typedef mat<3, 3, f64, lowp> lowp_f64mat3;
typedef mat<4, 4, f64, lowp> lowp_f64mat4;
typedef mat<2, 2, f64, mediump> mediump_f64mat2;
typedef mat<3, 3, f64, mediump> mediump_f64mat3;
typedef mat<4, 4, f64, mediump> mediump_f64mat4;
typedef mat<2, 2, f64, highp> highp_f64mat2;
typedef mat<3, 3, f64, highp> highp_f64mat3;
typedef mat<4, 4, f64, highp> highp_f64mat4;
typedef mat<2, 2, f64, defaultp> f64mat2;
typedef mat<3, 3, f64, defaultp> f64mat3;
typedef mat<4, 4, f64, defaultp> f64mat4;
// Matrix MxN
typedef mat<2, 2, f32, lowp> lowp_mat2x2;
typedef mat<2, 3, f32, lowp> lowp_mat2x3;
typedef mat<2, 4, f32, lowp> lowp_mat2x4;
typedef mat<3, 2, f32, lowp> lowp_mat3x2;
typedef mat<3, 3, f32, lowp> lowp_mat3x3;
typedef mat<3, 4, f32, lowp> lowp_mat3x4;
typedef mat<4, 2, f32, lowp> lowp_mat4x2;
typedef mat<4, 3, f32, lowp> lowp_mat4x3;
typedef mat<4, 4, f32, lowp> lowp_mat4x4;
typedef mat<2, 2, f32, mediump> mediump_mat2x2;
typedef mat<2, 3, f32, mediump> mediump_mat2x3;
typedef mat<2, 4, f32, mediump> mediump_mat2x4;
typedef mat<3, 2, f32, mediump> mediump_mat3x2;
typedef mat<3, 3, f32, mediump> mediump_mat3x3;
typedef mat<3, 4, f32, mediump> mediump_mat3x4;
typedef mat<4, 2, f32, mediump> mediump_mat4x2;
typedef mat<4, 3, f32, mediump> mediump_mat4x3;
typedef mat<4, 4, f32, mediump> mediump_mat4x4;
typedef mat<2, 2, f32, highp> highp_mat2x2;
typedef mat<2, 3, f32, highp> highp_mat2x3;
typedef mat<2, 4, f32, highp> highp_mat2x4;
typedef mat<3, 2, f32, highp> highp_mat3x2;
typedef mat<3, 3, f32, highp> highp_mat3x3;
typedef mat<3, 4, f32, highp> highp_mat3x4;
typedef mat<4, 2, f32, highp> highp_mat4x2;
typedef mat<4, 3, f32, highp> highp_mat4x3;
typedef mat<4, 4, f32, highp> highp_mat4x4;
typedef mat<2, 2, f32, defaultp> mat2x2;
typedef mat<3, 2, f32, defaultp> mat3x2;
typedef mat<4, 2, f32, defaultp> mat4x2;
typedef mat<2, 3, f32, defaultp> mat2x3;
typedef mat<3, 3, f32, defaultp> mat3x3;
typedef mat<4, 3, f32, defaultp> mat4x3;
typedef mat<2, 4, f32, defaultp> mat2x4;
typedef mat<3, 4, f32, defaultp> mat3x4;
typedef mat<4, 4, f32, defaultp> mat4x4;
typedef mat<2, 2, f32, lowp> lowp_fmat2x2;
typedef mat<2, 3, f32, lowp> lowp_fmat2x3;
typedef mat<2, 4, f32, lowp> lowp_fmat2x4;
typedef mat<3, 2, f32, lowp> lowp_fmat3x2;
typedef mat<3, 3, f32, lowp> lowp_fmat3x3;
typedef mat<3, 4, f32, lowp> lowp_fmat3x4;
typedef mat<4, 2, f32, lowp> lowp_fmat4x2;
typedef mat<4, 3, f32, lowp> lowp_fmat4x3;
typedef mat<4, 4, f32, lowp> lowp_fmat4x4;
typedef mat<2, 2, f32, mediump> mediump_fmat2x2;
typedef mat<2, 3, f32, mediump> mediump_fmat2x3;
typedef mat<2, 4, f32, mediump> mediump_fmat2x4;
typedef mat<3, 2, f32, mediump> mediump_fmat3x2;
typedef mat<3, 3, f32, mediump> mediump_fmat3x3;
typedef mat<3, 4, f32, mediump> mediump_fmat3x4;
typedef mat<4, 2, f32, mediump> mediump_fmat4x2;
typedef mat<4, 3, f32, mediump> mediump_fmat4x3;
typedef mat<4, 4, f32, mediump> mediump_fmat4x4;
typedef mat<2, 2, f32, highp> highp_fmat2x2;
typedef mat<2, 3, f32, highp> highp_fmat2x3;
typedef mat<2, 4, f32, highp> highp_fmat2x4;
typedef mat<3, 2, f32, highp> highp_fmat3x2;
typedef mat<3, 3, f32, highp> highp_fmat3x3;
typedef mat<3, 4, f32, highp> highp_fmat3x4;
typedef mat<4, 2, f32, highp> highp_fmat4x2;
typedef mat<4, 3, f32, highp> highp_fmat4x3;
typedef mat<4, 4, f32, highp> highp_fmat4x4;
typedef mat<2, 2, f32, defaultp> fmat2x2;
typedef mat<3, 2, f32, defaultp> fmat3x2;
typedef mat<4, 2, f32, defaultp> fmat4x2;
typedef mat<2, 3, f32, defaultp> fmat2x3;
typedef mat<3, 3, f32, defaultp> fmat3x3;
typedef mat<4, 3, f32, defaultp> fmat4x3;
typedef mat<2, 4, f32, defaultp> fmat2x4;
typedef mat<3, 4, f32, defaultp> fmat3x4;
typedef mat<4, 4, f32, defaultp> fmat4x4;
typedef mat<2, 2, f32, lowp> lowp_f32mat2x2;
typedef mat<2, 3, f32, lowp> lowp_f32mat2x3;
typedef mat<2, 4, f32, lowp> lowp_f32mat2x4;
typedef mat<3, 2, f32, lowp> lowp_f32mat3x2;
typedef mat<3, 3, f32, lowp> lowp_f32mat3x3;
typedef mat<3, 4, f32, lowp> lowp_f32mat3x4;
typedef mat<4, 2, f32, lowp> lowp_f32mat4x2;
typedef mat<4, 3, f32, lowp> lowp_f32mat4x3;
typedef mat<4, 4, f32, lowp> lowp_f32mat4x4;
typedef mat<2, 2, f32, mediump> mediump_f32mat2x2;
typedef mat<2, 3, f32, mediump> mediump_f32mat2x3;
typedef mat<2, 4, f32, mediump> mediump_f32mat2x4;
typedef mat<3, 2, f32, mediump> mediump_f32mat3x2;
typedef mat<3, 3, f32, mediump> mediump_f32mat3x3;
typedef mat<3, 4, f32, mediump> mediump_f32mat3x4;
typedef mat<4, 2, f32, mediump> mediump_f32mat4x2;
typedef mat<4, 3, f32, mediump> mediump_f32mat4x3;
typedef mat<4, 4, f32, mediump> mediump_f32mat4x4;
typedef mat<2, 2, f32, highp> highp_f32mat2x2;
typedef mat<2, 3, f32, highp> highp_f32mat2x3;
typedef mat<2, 4, f32, highp> highp_f32mat2x4;
typedef mat<3, 2, f32, highp> highp_f32mat3x2;
typedef mat<3, 3, f32, highp> highp_f32mat3x3;
typedef mat<3, 4, f32, highp> highp_f32mat3x4;
typedef mat<4, 2, f32, highp> highp_f32mat4x2;
typedef mat<4, 3, f32, highp> highp_f32mat4x3;
typedef mat<4, 4, f32, highp> highp_f32mat4x4;
typedef mat<2, 2, f32, defaultp> f32mat2x2;
typedef mat<3, 2, f32, defaultp> f32mat3x2;
typedef mat<4, 2, f32, defaultp> f32mat4x2;
typedef mat<2, 3, f32, defaultp> f32mat2x3;
typedef mat<3, 3, f32, defaultp> f32mat3x3;
typedef mat<4, 3, f32, defaultp> f32mat4x3;
typedef mat<2, 4, f32, defaultp> f32mat2x4;
typedef mat<3, 4, f32, defaultp> f32mat3x4;
typedef mat<4, 4, f32, defaultp> f32mat4x4;
typedef mat<2, 2, double, lowp> lowp_dmat2x2;
typedef mat<2, 3, double, lowp> lowp_dmat2x3;
typedef mat<2, 4, double, lowp> lowp_dmat2x4;
typedef mat<3, 2, double, lowp> lowp_dmat3x2;
typedef mat<3, 3, double, lowp> lowp_dmat3x3;
typedef mat<3, 4, double, lowp> lowp_dmat3x4;
typedef mat<4, 2, double, lowp> lowp_dmat4x2;
typedef mat<4, 3, double, lowp> lowp_dmat4x3;
typedef mat<4, 4, double, lowp> lowp_dmat4x4;
typedef mat<2, 2, double, mediump> mediump_dmat2x2;
typedef mat<2, 3, double, mediump> mediump_dmat2x3;
typedef mat<2, 4, double, mediump> mediump_dmat2x4;
typedef mat<3, 2, double, mediump> mediump_dmat3x2;
typedef mat<3, 3, double, mediump> mediump_dmat3x3;
typedef mat<3, 4, double, mediump> mediump_dmat3x4;
typedef mat<4, 2, double, mediump> mediump_dmat4x2;
typedef mat<4, 3, double, mediump> mediump_dmat4x3;
typedef mat<4, 4, double, mediump> mediump_dmat4x4;
typedef mat<2, 2, double, highp> highp_dmat2x2;
typedef mat<2, 3, double, highp> highp_dmat2x3;
typedef mat<2, 4, double, highp> highp_dmat2x4;
typedef mat<3, 2, double, highp> highp_dmat3x2;
typedef mat<3, 3, double, highp> highp_dmat3x3;
typedef mat<3, 4, double, highp> highp_dmat3x4;
typedef mat<4, 2, double, highp> highp_dmat4x2;
typedef mat<4, 3, double, highp> highp_dmat4x3;
typedef mat<4, 4, double, highp> highp_dmat4x4;
typedef mat<2, 2, double, defaultp> dmat2x2;
typedef mat<3, 2, double, defaultp> dmat3x2;
typedef mat<4, 2, double, defaultp> dmat4x2;
typedef mat<2, 3, double, defaultp> dmat2x3;
typedef mat<3, 3, double, defaultp> dmat3x3;
typedef mat<4, 3, double, defaultp> dmat4x3;
typedef mat<2, 4, double, defaultp> dmat2x4;
typedef mat<3, 4, double, defaultp> dmat3x4;
typedef mat<4, 4, double, defaultp> dmat4x4;
typedef mat<2, 2, f64, lowp> lowp_f64mat2x2;
typedef mat<2, 3, f64, lowp> lowp_f64mat2x3;
typedef mat<2, 4, f64, lowp> lowp_f64mat2x4;
typedef mat<3, 2, f64, lowp> lowp_f64mat3x2;
typedef mat<3, 3, f64, lowp> lowp_f64mat3x3;
typedef mat<3, 4, f64, lowp> lowp_f64mat3x4;
typedef mat<4, 2, f64, lowp> lowp_f64mat4x2;
typedef mat<4, 3, f64, lowp> lowp_f64mat4x3;
typedef mat<4, 4, f64, lowp> lowp_f64mat4x4;
typedef mat<2, 2, f64, mediump> mediump_f64mat2x2;
typedef mat<2, 3, f64, mediump> mediump_f64mat2x3;
typedef mat<2, 4, f64, mediump> mediump_f64mat2x4;
typedef mat<3, 2, f64, mediump> mediump_f64mat3x2;
typedef mat<3, 3, f64, mediump> mediump_f64mat3x3;
typedef mat<3, 4, f64, mediump> mediump_f64mat3x4;
typedef mat<4, 2, f64, mediump> mediump_f64mat4x2;
typedef mat<4, 3, f64, mediump> mediump_f64mat4x3;
typedef mat<4, 4, f64, mediump> mediump_f64mat4x4;
typedef mat<2, 2, f64, highp> highp_f64mat2x2;
typedef mat<2, 3, f64, highp> highp_f64mat2x3;
typedef mat<2, 4, f64, highp> highp_f64mat2x4;
typedef mat<3, 2, f64, highp> highp_f64mat3x2;
typedef mat<3, 3, f64, highp> highp_f64mat3x3;
typedef mat<3, 4, f64, highp> highp_f64mat3x4;
typedef mat<4, 2, f64, highp> highp_f64mat4x2;
typedef mat<4, 3, f64, highp> highp_f64mat4x3;
typedef mat<4, 4, f64, highp> highp_f64mat4x4;
typedef mat<2, 2, f64, defaultp> f64mat2x2;
typedef mat<3, 2, f64, defaultp> f64mat3x2;
typedef mat<4, 2, f64, defaultp> f64mat4x2;
typedef mat<2, 3, f64, defaultp> f64mat2x3;
typedef mat<3, 3, f64, defaultp> f64mat3x3;
typedef mat<4, 3, f64, defaultp> f64mat4x3;
typedef mat<2, 4, f64, defaultp> f64mat2x4;
typedef mat<3, 4, f64, defaultp> f64mat3x4;
typedef mat<4, 4, f64, defaultp> f64mat4x4;
// Quaternion
typedef qua<float, lowp> lowp_quat;
typedef qua<float, mediump> mediump_quat;
typedef qua<float, highp> highp_quat;
typedef qua<float, defaultp> quat;
typedef qua<float, lowp> lowp_fquat;
typedef qua<float, mediump> mediump_fquat;
typedef qua<float, highp> highp_fquat;
typedef qua<float, defaultp> fquat;
typedef qua<f32, lowp> lowp_f32quat;
typedef qua<f32, mediump> mediump_f32quat;
typedef qua<f32, highp> highp_f32quat;
typedef qua<f32, defaultp> f32quat;
typedef qua<double, lowp> lowp_dquat;
typedef qua<double, mediump> mediump_dquat;
typedef qua<double, highp> highp_dquat;
typedef qua<double, defaultp> dquat;
typedef qua<f64, lowp> lowp_f64quat;
typedef qua<f64, mediump> mediump_f64quat;
typedef qua<f64, highp> highp_f64quat;
typedef qua<f64, defaultp> f64quat;
}//namespace glm
| Unknown |
3D | mcellteam/mcell | libs/glm/mat3x2.hpp | .hpp | 233 | 10 | /// @ref core
/// @file glm/mat3x2.hpp
#pragma once
#include "./ext/matrix_double3x2.hpp"
#include "./ext/matrix_double3x2_precision.hpp"
#include "./ext/matrix_float3x2.hpp"
#include "./ext/matrix_float3x2_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/packing.hpp | .hpp | 11,070 | 174 | /// @ref core
/// @file glm/packing.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
/// @see gtc_packing
///
/// @defgroup core_func_packing Floating-Point Pack and Unpack Functions
/// @ingroup core
///
/// Provides GLSL functions to pack and unpack half, single and double-precision floating point values into more compact integer types.
///
/// These functions do not operate component-wise, rather as described in each case.
///
/// Include <glm/packing.hpp> to use these core features.
#pragma once
#include "./ext/vector_uint2.hpp"
#include "./ext/vector_float2.hpp"
#include "./ext/vector_float4.hpp"
namespace glm
{
/// @addtogroup core_func_packing
/// @{
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packUnorm2x16: round(clamp(c, 0, +1) * 65535.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// the last component will be written to the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm2x16.xml">GLSL packUnorm2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL uint packUnorm2x16(vec2 const& v);
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packSnorm2x16: round(clamp(v, -1, +1) * 32767.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// the last component will be written to the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm2x16.xml">GLSL packSnorm2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL uint packSnorm2x16(vec2 const& v);
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packUnorm4x8: round(clamp(c, 0, +1) * 255.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// the last component will be written to the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL uint packUnorm4x8(vec4 const& v);
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
///
/// The conversion for component c of v to fixed point is done as follows:
/// packSnorm4x8: round(clamp(c, -1, +1) * 127.0)
///
/// The first component of the vector will be written to the least significant bits of the output;
/// the last component will be written to the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL uint packSnorm4x8(vec4 const& v);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
///
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
/// unpackUnorm2x16: f / 65535.0
///
/// The first component of the returned vector will be extracted from the least significant bits of the input;
/// the last component will be extracted from the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL vec2 unpackUnorm2x16(uint p);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
///
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
/// unpackSnorm2x16: clamp(f / 32767.0, -1, +1)
///
/// The first component of the returned vector will be extracted from the least significant bits of the input;
/// the last component will be extracted from the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm2x16.xml">GLSL unpackSnorm2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL vec2 unpackSnorm2x16(uint p);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
///
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
/// unpackUnorm4x8: f / 255.0
///
/// The first component of the returned vector will be extracted from the least significant bits of the input;
/// the last component will be extracted from the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL vec4 unpackUnorm4x8(uint p);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
///
/// The conversion for unpacked fixed-point value f to floating point is done as follows:
/// unpackSnorm4x8: clamp(f / 127.0, -1, +1)
///
/// The first component of the returned vector will be extracted from the least significant bits of the input;
/// the last component will be extracted from the most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL vec4 unpackSnorm4x8(uint p);
/// Returns a double-qualifier value obtained by packing the components of v into a 64-bit value.
/// If an IEEE 754 Inf or NaN is created, it will not signal, and the resulting floating point value is unspecified.
/// Otherwise, the bit- level representation of v is preserved.
/// The first vector component specifies the 32 least significant bits;
/// the second component specifies the 32 most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packDouble2x32.xml">GLSL packDouble2x32 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL double packDouble2x32(uvec2 const& v);
/// Returns a two-component unsigned integer vector representation of v.
/// The bit-level representation of v is preserved.
/// The first component of the vector contains the 32 least significant bits of the double;
/// the second component consists the 32 most significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackDouble2x32.xml">GLSL unpackDouble2x32 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL uvec2 unpackDouble2x32(double v);
/// Returns an unsigned integer obtained by converting the components of a two-component floating-point vector
/// to the 16-bit floating-point representation found in the OpenGL Specification,
/// and then packing these two 16- bit integers into a 32-bit unsigned integer.
/// The first vector component specifies the 16 least-significant bits of the result;
/// the second component specifies the 16 most-significant bits.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL uint packHalf2x16(vec2 const& v);
/// Returns a two-component floating-point vector with components obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values,
/// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
/// and converting them to 32-bit floating-point values.
/// The first component of the vector is obtained from the 16 least-significant bits of v;
/// the second component is obtained from the 16 most-significant bits of v.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
GLM_FUNC_DECL vec2 unpackHalf2x16(uint v);
/// @}
}//namespace glm
#include "detail/func_packing.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/trigonometric.hpp | .hpp | 10,885 | 211 | /// @ref core
/// @file glm/trigonometric.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
///
/// @defgroup core_func_trigonometric Angle and Trigonometry Functions
/// @ingroup core
///
/// Function parameters specified as angle are assumed to be in units of radians.
/// In no case will any of these functions result in a divide by zero error. If
/// the divisor of a ratio is 0, then results will be undefined.
///
/// These all operate component-wise. The description is per component.
///
/// Include <glm/trigonometric.hpp> to use these core features.
///
/// @see ext_vector_trigonometric
#pragma once
#include "detail/setup.hpp"
#include "detail/qualifier.hpp"
namespace glm
{
/// @addtogroup core_func_trigonometric
/// @{
/// Converts degrees to radians and returns the result.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> radians(vec<L, T, Q> const& degrees);
/// Converts radians to degrees and returns the result.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> degrees(vec<L, T, Q> const& radians);
/// The standard trigonometric sine function.
/// The values returned by this function will range from [-1, 1].
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sin.xml">GLSL sin man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> sin(vec<L, T, Q> const& angle);
/// The standard trigonometric cosine function.
/// The values returned by this function will range from [-1, 1].
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cos.xml">GLSL cos man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> cos(vec<L, T, Q> const& angle);
/// The standard trigonometric tangent function.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tan.xml">GLSL tan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> tan(vec<L, T, Q> const& angle);
/// Arc sine. Returns an angle whose sine is x.
/// The range of values returned by this function is [-PI/2, PI/2].
/// Results are undefined if |x| > 1.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asin.xml">GLSL asin man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> asin(vec<L, T, Q> const& x);
/// Arc cosine. Returns an angle whose sine is x.
/// The range of values returned by this function is [0, PI].
/// Results are undefined if |x| > 1.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acos.xml">GLSL acos man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> acos(vec<L, T, Q> const& x);
/// Arc tangent. Returns an angle whose tangent is y/x.
/// The signs of x and y are used to determine what
/// quadrant the angle is in. The range of values returned
/// by this function is [-PI, PI]. Results are undefined
/// if x and y are both 0.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> atan(vec<L, T, Q> const& y, vec<L, T, Q> const& x);
/// Arc tangent. Returns an angle whose tangent is y_over_x.
/// The range of values returned by this function is [-PI/2, PI/2].
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> atan(vec<L, T, Q> const& y_over_x);
/// Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sinh.xml">GLSL sinh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> sinh(vec<L, T, Q> const& angle);
/// Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cosh.xml">GLSL cosh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> cosh(vec<L, T, Q> const& angle);
/// Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tanh.xml">GLSL tanh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> tanh(vec<L, T, Q> const& angle);
/// Arc hyperbolic sine; returns the inverse of sinh.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asinh.xml">GLSL asinh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> asinh(vec<L, T, Q> const& x);
/// Arc hyperbolic cosine; returns the non-negative inverse
/// of cosh. Results are undefined if x < 1.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acosh.xml">GLSL acosh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> acosh(vec<L, T, Q> const& x);
/// Arc hyperbolic tangent; returns the inverse of tanh.
/// Results are undefined if abs(x) >= 1.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atanh.xml">GLSL atanh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> atanh(vec<L, T, Q> const& x);
/// @}
}//namespace glm
#include "detail/func_trigonometric.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/integer.hpp | .hpp | 10,688 | 213 | /// @ref core
/// @file glm/integer.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
///
/// @defgroup core_func_integer Integer functions
/// @ingroup core
///
/// Provides GLSL functions on integer types
///
/// These all operate component-wise. The description is per component.
/// The notation [a, b] means the set of bits from bit-number a through bit-number
/// b, inclusive. The lowest-order bit is bit 0.
///
/// Include <glm/integer.hpp> to use these core features.
#pragma once
#include "detail/qualifier.hpp"
#include "common.hpp"
#include "vector_relational.hpp"
namespace glm
{
/// @addtogroup core_func_integer
/// @{
/// Adds 32-bit unsigned integer x and y, returning the sum
/// modulo pow(2, 32). The value carry is set to 0 if the sum was
/// less than pow(2, 32), or to 1 otherwise.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uaddCarry.xml">GLSL uaddCarry man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL vec<L, uint, Q> uaddCarry(
vec<L, uint, Q> const& x,
vec<L, uint, Q> const& y,
vec<L, uint, Q> & carry);
/// Subtracts the 32-bit unsigned integer y from x, returning
/// the difference if non-negative, or pow(2, 32) plus the difference
/// otherwise. The value borrow is set to 0 if x >= y, or to 1 otherwise.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/usubBorrow.xml">GLSL usubBorrow man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL vec<L, uint, Q> usubBorrow(
vec<L, uint, Q> const& x,
vec<L, uint, Q> const& y,
vec<L, uint, Q> & borrow);
/// Multiplies 32-bit integers x and y, producing a 64-bit
/// result. The 32 least-significant bits are returned in lsb.
/// The 32 most-significant bits are returned in msb.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/umulExtended.xml">GLSL umulExtended man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL void umulExtended(
vec<L, uint, Q> const& x,
vec<L, uint, Q> const& y,
vec<L, uint, Q> & msb,
vec<L, uint, Q> & lsb);
/// Multiplies 32-bit integers x and y, producing a 64-bit
/// result. The 32 least-significant bits are returned in lsb.
/// The 32 most-significant bits are returned in msb.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/imulExtended.xml">GLSL imulExtended man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL void imulExtended(
vec<L, int, Q> const& x,
vec<L, int, Q> const& y,
vec<L, int, Q> & msb,
vec<L, int, Q> & lsb);
/// Extracts bits [offset, offset + bits - 1] from value,
/// returning them in the least significant bits of the result.
/// For unsigned data types, the most significant bits of the
/// result will be set to zero. For signed data types, the
/// most significant bits will be set to the value of bit offset + base - 1.
///
/// If bits is zero, the result will be zero. The result will be
/// undefined if offset or bits is negative, or if the sum of
/// offset and bits is greater than the number of bits used
/// to store the operand.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Signed or unsigned integer scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldExtract.xml">GLSL bitfieldExtract man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> bitfieldExtract(
vec<L, T, Q> const& Value,
int Offset,
int Bits);
/// Returns the insertion the bits least-significant bits of insert into base.
///
/// The result will have bits [offset, offset + bits - 1] taken
/// from bits [0, bits - 1] of insert, and all other bits taken
/// directly from the corresponding bits of base. If bits is
/// zero, the result will simply be base. The result will be
/// undefined if offset or bits is negative, or if the sum of
/// offset and bits is greater than the number of bits used to
/// store the operand.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Signed or unsigned integer scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldInsert.xml">GLSL bitfieldInsert man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> bitfieldInsert(
vec<L, T, Q> const& Base,
vec<L, T, Q> const& Insert,
int Offset,
int Bits);
/// Returns the reversal of the bits of value.
/// The bit numbered n of the result will be taken from bit (bits - 1) - n of value,
/// where bits is the total number of bits used to represent value.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Signed or unsigned integer scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldReverse.xml">GLSL bitfieldReverse man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> bitfieldReverse(vec<L, T, Q> const& v);
/// Returns the number of bits set to 1 in the binary representation of value.
///
/// @tparam genType Signed or unsigned integer scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<typename genType>
GLM_FUNC_DECL int bitCount(genType v);
/// Returns the number of bits set to 1 in the binary representation of value.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Signed or unsigned integer scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, int, Q> bitCount(vec<L, T, Q> const& v);
/// Returns the bit number of the least significant bit set to
/// 1 in the binary representation of value.
/// If value is zero, -1 will be returned.
///
/// @tparam genIUType Signed or unsigned integer scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<typename genIUType>
GLM_FUNC_DECL int findLSB(genIUType x);
/// Returns the bit number of the least significant bit set to
/// 1 in the binary representation of value.
/// If value is zero, -1 will be returned.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Signed or unsigned integer scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, int, Q> findLSB(vec<L, T, Q> const& v);
/// Returns the bit number of the most significant bit in the binary representation of value.
/// For positive integers, the result will be the bit number of the most significant bit set to 1.
/// For negative integers, the result will be the bit number of the most significant
/// bit set to 0. For a value of zero or negative one, -1 will be returned.
///
/// @tparam genIUType Signed or unsigned integer scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<typename genIUType>
GLM_FUNC_DECL int findMSB(genIUType x);
/// Returns the bit number of the most significant bit in the binary representation of value.
/// For positive integers, the result will be the bit number of the most significant bit set to 1.
/// For negative integers, the result will be the bit number of the most significant
/// bit set to 0. For a value of zero or negative one, -1 will be returned.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Signed or unsigned integer scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, int, Q> findMSB(vec<L, T, Q> const& v);
/// @}
}//namespace glm
#include "detail/func_integer.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat4x2.hpp | .hpp | 233 | 10 | /// @ref core
/// @file glm/mat4x2.hpp
#pragma once
#include "./ext/matrix_double4x2.hpp"
#include "./ext/matrix_double4x2_precision.hpp"
#include "./ext/matrix_float4x2.hpp"
#include "./ext/matrix_float4x2_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat4x3.hpp | .hpp | 231 | 9 | /// @ref core
/// @file glm/mat4x3.hpp
#pragma once
#include "./ext/matrix_double4x3.hpp"
#include "./ext/matrix_double4x3_precision.hpp"
#include "./ext/matrix_float4x3.hpp"
#include "./ext/matrix_float4x3_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/exponential.hpp | .hpp | 5,725 | 111 | /// @ref core
/// @file glm/exponential.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
///
/// @defgroup core_func_exponential Exponential functions
/// @ingroup core
///
/// Provides GLSL exponential functions
///
/// These all operate component-wise. The description is per component.
///
/// Include <glm/exponential.hpp> to use these core features.
#pragma once
#include "detail/type_vec1.hpp"
#include "detail/type_vec2.hpp"
#include "detail/type_vec3.hpp"
#include "detail/type_vec4.hpp"
#include <cmath>
namespace glm
{
/// @addtogroup core_func_exponential
/// @{
/// Returns 'base' raised to the power 'exponent'.
///
/// @param base Floating point value. pow function is defined for input values of 'base' defined in the range (inf-, inf+) in the limit of the type qualifier.
/// @param exponent Floating point value representing the 'exponent'.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/pow.xml">GLSL pow man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> pow(vec<L, T, Q> const& base, vec<L, T, Q> const& exponent);
/// Returns the natural exponentiation of x, i.e., e^x.
///
/// @param v exp function is defined for input values of v defined in the range (inf-, inf+) in the limit of the type qualifier.
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/exp.xml">GLSL exp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> exp(vec<L, T, Q> const& v);
/// Returns the natural logarithm of v, i.e.,
/// returns the value y which satisfies the equation x = e^y.
/// Results are undefined if v <= 0.
///
/// @param v log function is defined for input values of v defined in the range (0, inf+) in the limit of the type qualifier.
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/log.xml">GLSL log man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> log(vec<L, T, Q> const& v);
/// Returns 2 raised to the v power.
///
/// @param v exp2 function is defined for input values of v defined in the range (inf-, inf+) in the limit of the type qualifier.
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/exp2.xml">GLSL exp2 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> exp2(vec<L, T, Q> const& v);
/// Returns the base 2 log of x, i.e., returns the value y,
/// which satisfies the equation x = 2 ^ y.
///
/// @param v log2 function is defined for input values of v defined in the range (0, inf+) in the limit of the type qualifier.
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/log2.xml">GLSL log2 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> log2(vec<L, T, Q> const& v);
/// Returns the positive square root of v.
///
/// @param v sqrt function is defined for input values of v defined in the range [0, inf+) in the limit of the type qualifier.
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sqrt.xml">GLSL sqrt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> sqrt(vec<L, T, Q> const& v);
/// Returns the reciprocal of the positive square root of v.
///
/// @param v inversesqrt function is defined for input values of v defined in the range [0, inf+) in the limit of the type qualifier.
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inversesqrt.xml">GLSL inversesqrt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> inversesqrt(vec<L, T, Q> const& v);
/// @}
}//namespace glm
#include "detail/func_exponential.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat2x3.hpp | .hpp | 233 | 10 | /// @ref core
/// @file glm/mat2x3.hpp
#pragma once
#include "./ext/matrix_double2x3.hpp"
#include "./ext/matrix_double2x3_precision.hpp"
#include "./ext/matrix_float2x3.hpp"
#include "./ext/matrix_float2x3_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat3x3.hpp | .hpp | 231 | 9 | /// @ref core
/// @file glm/mat3x3.hpp
#pragma once
#include "./ext/matrix_double3x3.hpp"
#include "./ext/matrix_double3x3_precision.hpp"
#include "./ext/matrix_float3x3.hpp"
#include "./ext/matrix_float3x3_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat2x2.hpp | .hpp | 233 | 10 | /// @ref core
/// @file glm/mat2x2.hpp
#pragma once
#include "./ext/matrix_double2x2.hpp"
#include "./ext/matrix_double2x2_precision.hpp"
#include "./ext/matrix_float2x2.hpp"
#include "./ext/matrix_float2x2_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/ext.hpp | .hpp | 6,674 | 197 | /// @file glm/ext.hpp
///
/// @ref core (Dependence)
#include "detail/setup.hpp"
#pragma once
#include "glm.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_EXT_INCLUDED_DISPLAYED)
# define GLM_MESSAGE_EXT_INCLUDED_DISPLAYED
# pragma message("GLM: All extensions included (not recommended)")
#endif//GLM_MESSAGES
#include "./ext/matrix_double2x2.hpp"
#include "./ext/matrix_double2x2_precision.hpp"
#include "./ext/matrix_double2x3.hpp"
#include "./ext/matrix_double2x3_precision.hpp"
#include "./ext/matrix_double2x4.hpp"
#include "./ext/matrix_double2x4_precision.hpp"
#include "./ext/matrix_double3x2.hpp"
#include "./ext/matrix_double3x2_precision.hpp"
#include "./ext/matrix_double3x3.hpp"
#include "./ext/matrix_double3x3_precision.hpp"
#include "./ext/matrix_double3x4.hpp"
#include "./ext/matrix_double3x4_precision.hpp"
#include "./ext/matrix_double4x2.hpp"
#include "./ext/matrix_double4x2_precision.hpp"
#include "./ext/matrix_double4x3.hpp"
#include "./ext/matrix_double4x3_precision.hpp"
#include "./ext/matrix_double4x4.hpp"
#include "./ext/matrix_double4x4_precision.hpp"
#include "./ext/matrix_float2x2.hpp"
#include "./ext/matrix_float2x2_precision.hpp"
#include "./ext/matrix_float2x3.hpp"
#include "./ext/matrix_float2x3_precision.hpp"
#include "./ext/matrix_float2x4.hpp"
#include "./ext/matrix_float2x4_precision.hpp"
#include "./ext/matrix_float3x2.hpp"
#include "./ext/matrix_float3x2_precision.hpp"
#include "./ext/matrix_float3x3.hpp"
#include "./ext/matrix_float3x3_precision.hpp"
#include "./ext/matrix_float3x4.hpp"
#include "./ext/matrix_float3x4_precision.hpp"
#include "./ext/matrix_float4x2.hpp"
#include "./ext/matrix_float4x2_precision.hpp"
#include "./ext/matrix_float4x3.hpp"
#include "./ext/matrix_float4x3_precision.hpp"
#include "./ext/matrix_float4x4.hpp"
#include "./ext/matrix_float4x4_precision.hpp"
#include "./ext/matrix_relational.hpp"
#include "./ext/quaternion_double.hpp"
#include "./ext/quaternion_double_precision.hpp"
#include "./ext/quaternion_float.hpp"
#include "./ext/quaternion_float_precision.hpp"
#include "./ext/quaternion_geometric.hpp"
#include "./ext/quaternion_relational.hpp"
#include "./ext/scalar_constants.hpp"
#include "./ext/scalar_int_sized.hpp"
#include "./ext/scalar_relational.hpp"
#include "./ext/vector_bool1.hpp"
#include "./ext/vector_bool1_precision.hpp"
#include "./ext/vector_bool2.hpp"
#include "./ext/vector_bool2_precision.hpp"
#include "./ext/vector_bool3.hpp"
#include "./ext/vector_bool3_precision.hpp"
#include "./ext/vector_bool4.hpp"
#include "./ext/vector_bool4_precision.hpp"
#include "./ext/vector_double1.hpp"
#include "./ext/vector_double1_precision.hpp"
#include "./ext/vector_double2.hpp"
#include "./ext/vector_double2_precision.hpp"
#include "./ext/vector_double3.hpp"
#include "./ext/vector_double3_precision.hpp"
#include "./ext/vector_double4.hpp"
#include "./ext/vector_double4_precision.hpp"
#include "./ext/vector_float1.hpp"
#include "./ext/vector_float1_precision.hpp"
#include "./ext/vector_float2.hpp"
#include "./ext/vector_float2_precision.hpp"
#include "./ext/vector_float3.hpp"
#include "./ext/vector_float3_precision.hpp"
#include "./ext/vector_float4.hpp"
#include "./ext/vector_float4_precision.hpp"
#include "./ext/vector_int1.hpp"
#include "./ext/vector_int1_precision.hpp"
#include "./ext/vector_int2.hpp"
#include "./ext/vector_int2_precision.hpp"
#include "./ext/vector_int3.hpp"
#include "./ext/vector_int3_precision.hpp"
#include "./ext/vector_int4.hpp"
#include "./ext/vector_int4_precision.hpp"
#include "./ext/vector_relational.hpp"
#include "./ext/vector_uint1.hpp"
#include "./ext/vector_uint1_precision.hpp"
#include "./ext/vector_uint2.hpp"
#include "./ext/vector_uint2_precision.hpp"
#include "./ext/vector_uint3.hpp"
#include "./ext/vector_uint3_precision.hpp"
#include "./ext/vector_uint4.hpp"
#include "./ext/vector_uint4_precision.hpp"
#include "./gtc/bitfield.hpp"
#include "./gtc/color_space.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"
#if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE
# include "./gtc/type_aligned.hpp"
#endif
#ifdef GLM_ENABLE_EXPERIMENTAL
#include "./gtx/associated_min_max.hpp"
#include "./gtx/bit.hpp"
#include "./gtx/closest_point.hpp"
#include "./gtx/color_encoding.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/extended_min_max.hpp"
#include "./gtx/fast_exponential.hpp"
#include "./gtx/fast_square_root.hpp"
#include "./gtx/fast_trigonometry.hpp"
#include "./gtx/functions.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/vec_swizzle.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
#endif//GLM_ENABLE_EXPERIMENTAL
| Unknown |
3D | mcellteam/mcell | libs/glm/vec4.hpp | .hpp | 461 | 16 | /// @ref core
/// @file glm/vec4.hpp
#pragma once
#include "./ext/vector_bool4.hpp"
#include "./ext/vector_bool4_precision.hpp"
#include "./ext/vector_float4.hpp"
#include "./ext/vector_float4_precision.hpp"
#include "./ext/vector_double4.hpp"
#include "./ext/vector_double4_precision.hpp"
#include "./ext/vector_int4.hpp"
#include "./ext/vector_int4_precision.hpp"
#include "./ext/vector_uint4.hpp"
#include "./ext/vector_uint4_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/glm.hpp | .hpp | 4,635 | 137 | /// @ref core
/// @file glm/glm.hpp
///
/// @defgroup core Core features
///
/// @brief Features that implement in C++ the GLSL specification as closely as possible.
///
/// The GLM core consists of C++ types that mirror GLSL types and
/// C++ functions that mirror the GLSL functions.
///
/// 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 functionalities require <glm/glm.hpp> to be included to be used.
///
///
/// @defgroup core_vector Vector types
///
/// Vector types of two to four components with an exhaustive set of operators.
///
/// @ingroup core
///
///
/// @defgroup core_vector_precision Vector types with precision qualifiers
///
/// @brief Vector types with precision qualifiers which may result in various precision in term of ULPs
///
/// GLSL allows defining qualifiers for particular variables.
/// With OpenGL's GLSL, these qualifiers have no effect; they are there for compatibility,
/// with OpenGL ES's GLSL, these qualifiers do have an effect.
///
/// C++ has no language equivalent to qualifier qualifiers. So GLM provides the next-best thing:
/// a number of typedefs that use a particular qualifier.
///
/// None of these types make any guarantees about the actual qualifier used.
///
/// @ingroup core
///
///
/// @defgroup core_matrix Matrix types
///
/// Matrix types of with C columns and R rows where C and R are values between 2 to 4 included.
/// These types have exhaustive sets of operators.
///
/// @ingroup core
///
///
/// @defgroup core_matrix_precision Matrix types with precision qualifiers
///
/// @brief Matrix types with precision qualifiers which may result in various precision in term of ULPs
///
/// GLSL allows defining qualifiers for particular variables.
/// With OpenGL's GLSL, these qualifiers have no effect; they are there for compatibility,
/// with OpenGL ES's GLSL, these qualifiers do have an effect.
///
/// C++ has no language equivalent to qualifier qualifiers. So GLM provides the next-best thing:
/// a number of typedefs that use a particular qualifier.
///
/// None of these types make any guarantees about the actual qualifier used.
///
/// @ingroup core
///
///
/// @defgroup ext Stable extensions
///
/// @brief Additional features not specified by GLSL specification.
///
/// EXT extensions are fully tested and documented.
///
/// 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 gtc Recommended extensions
///
/// @brief Additional features not specified by GLSL specification.
///
/// GTC extensions aim to be stable with tests and documentation.
///
/// 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 Experimental extensions
///
/// @brief Experimental features not specified by GLSL specification.
///
/// 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.
///
/// @mainpage OpenGL Mathematics (GLM)
/// - Website: <a href="https://glm.g-truc.net">glm.g-truc.net</a>
/// - <a href="modules.html">GLM API documentation</a>
/// - <a href="https://github.com/g-truc/glm/blob/master/manual.md">GLM Manual</a>
#include "detail/_fixes.hpp"
#include "detail/setup.hpp"
#pragma once
#include <cmath>
#include <climits>
#include <cfloat>
#include <limits>
#include <cassert>
#include "fwd.hpp"
#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 |
3D | mcellteam/mcell | libs/glm/vec2.hpp | .hpp | 459 | 15 | /// @ref core
/// @file glm/vec2.hpp
#pragma once
#include "./ext/vector_bool2.hpp"
#include "./ext/vector_bool2_precision.hpp"
#include "./ext/vector_float2.hpp"
#include "./ext/vector_float2_precision.hpp"
#include "./ext/vector_double2.hpp"
#include "./ext/vector_double2_precision.hpp"
#include "./ext/vector_int2.hpp"
#include "./ext/vector_int2_precision.hpp"
#include "./ext/vector_uint2.hpp"
#include "./ext/vector_uint2_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/mat4x4.hpp | .hpp | 233 | 10 | /// @ref core
/// @file glm/mat4x4.hpp
#pragma once
#include "./ext/matrix_double4x4.hpp"
#include "./ext/matrix_double4x4_precision.hpp"
#include "./ext/matrix_float4x4.hpp"
#include "./ext/matrix_float4x4_precision.hpp"
| Unknown |
3D | mcellteam/mcell | libs/glm/vector_relational.hpp | .hpp | 6,464 | 122 | /// @ref core
/// @file glm/vector_relational.hpp
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
///
/// @defgroup core_func_vector_relational Vector Relational Functions
/// @ingroup core
///
/// Relational and equality operators (<, <=, >, >=, ==, !=) are defined to
/// operate on scalars and produce scalar Boolean results. For vector results,
/// use the following built-in functions.
///
/// In all cases, the sizes of all the input and return vectors for any particular
/// call must match.
///
/// Include <glm/vector_relational.hpp> to use these core features.
///
/// @see ext_vector_relational
#pragma once
#include "detail/qualifier.hpp"
#include "detail/setup.hpp"
namespace glm
{
/// @addtogroup core_func_vector_relational
/// @{
/// Returns the component-wise comparison result of x < y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T A floating-point or integer scalar type.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/lessThan.xml">GLSL lessThan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> lessThan(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the component-wise comparison of result x <= y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T A floating-point or integer scalar type.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/lessThanEqual.xml">GLSL lessThanEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> lessThanEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the component-wise comparison of result x > y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T A floating-point or integer scalar type.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/greaterThan.xml">GLSL greaterThan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> greaterThan(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the component-wise comparison of result x >= y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T A floating-point or integer scalar type.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/greaterThanEqual.xml">GLSL greaterThanEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> greaterThanEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the component-wise comparison of result x == y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T A floating-point, integer or bool scalar type.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/equal.xml">GLSL equal man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the component-wise comparison of result x != y.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
/// @tparam T A floating-point, integer or bool scalar type.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/notEqual.xml">GLSL notEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns true if any component of x is true.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/any.xml">GLSL any man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR bool any(vec<L, bool, Q> const& v);
/// Returns true if all components of x are true.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/all.xml">GLSL all man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR bool all(vec<L, bool, Q> const& v);
/// Returns the component-wise logical complement of x.
/// /!\ Because of language incompatibilities between C++ and GLSL, GLM defines the function not but not_ instead.
///
/// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/not.xml">GLSL not man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR vec<L, bool, Q> not_(vec<L, bool, Q> const& v);
/// @}
}//namespace glm
#include "detail/func_vector_relational.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_operation.hpp | .hpp | 3,135 | 104 | /// @ref gtx_matrix_operation
/// @file glm/gtx/matrix_operation.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_operation GLM_GTX_matrix_operation
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_operation.hpp> to use the features of this extension.
///
/// Build diagonal matrices from vectors.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_operation is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !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, qualifier Q>
GLM_FUNC_DECL mat<2, 2, T, Q> diagonal2x2(
vec<2, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 3, T, Q> diagonal2x3(
vec<2, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 4, T, Q> diagonal2x4(
vec<2, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 2, T, Q> diagonal3x2(
vec<2, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> diagonal3x3(
vec<3, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 4, T, Q> diagonal3x4(
vec<3, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 2, T, Q> diagonal4x2(
vec<2, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 3, T, Q> diagonal4x3(
vec<3, T, Q> const& v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> diagonal4x4(
vec<4, T, Q> const& v);
/// Build an adjugate matrix.
/// From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 2, T, Q> adjugate(mat<2, 2, T, Q> const& m);
/// Build an adjugate matrix.
/// From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> adjugate(mat<3, 3, T, Q> const& m);
/// Build an adjugate matrix.
/// From GLM_GTX_matrix_operation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> adjugate(mat<4, 4, T, Q> const& m);
/// @}
}//namespace glm
#include "matrix_operation.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_cross_product.hpp | .hpp | 1,352 | 48 | /// @ref gtx_matrix_cross_product
/// @file glm/gtx/matrix_cross_product.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_cross_product.hpp> to use the features of this extension.
///
/// Build cross product matrices
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_cross_product is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !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, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> matrixCross3(
vec<3, T, Q> const& x);
//! Build a cross product matrix.
//! From GLM_GTX_matrix_cross_product extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> matrixCross4(
vec<3, T, Q> const& x);
/// @}
}//namespace glm
#include "matrix_cross_product.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/closest_point.hpp | .hpp | 1,356 | 50 | /// @ref gtx_closest_point
/// @file glm/gtx/closest_point.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_closest_point GLM_GTX_closest_point
/// @ingroup gtx
///
/// Include <glm/gtx/closest_point.hpp> to use the features of this extension.
///
/// Find the point on a straight line which is the closet of a point.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_closest_point is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !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, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> closestPointOnLine(
vec<3, T, Q> const& point,
vec<3, T, Q> const& a,
vec<3, T, Q> const& b);
/// 2d lines work as well
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<2, T, Q> closestPointOnLine(
vec<2, T, Q> const& point,
vec<2, T, Q> const& a,
vec<2, T, Q> const& b);
/// @}
}// namespace glm
#include "closest_point.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/euler_angles.hpp | .hpp | 10,992 | 336 | /// @ref gtx_euler_angles
/// @file glm/gtx/euler_angles.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_euler_angles GLM_GTX_euler_angles
/// @ingroup gtx
///
/// Include <glm/gtx/euler_angles.hpp> to use the features of this extension.
///
/// Build matrices from Euler angles.
///
/// Extraction of Euler angles from rotation matrix.
/// Based on the original paper 2014 Mike Day - Extracting Euler Angles from a Rotation Matrix.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_euler_angles is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !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 mat<4, 4, 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 mat<4, 4, 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 mat<4, 4, T, defaultp> eulerAngleZ(
T const& angleZ);
/// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about X-axis.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleX(
T const & angleX, T const & angularVelocityX);
/// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about Y-axis.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleY(
T const & angleY, T const & angularVelocityY);
/// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about Z-axis.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleZ(
T const & angleZ, T const & angularVelocityZ);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y).
/// @see gtx_euler_angles
template<typename T>
GLM_FUNC_DECL mat<4, 4, 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 mat<4, 4, 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 mat<4, 4, 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 mat<4, 4, 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 mat<4, 4, 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 mat<4, 4, T, defaultp> eulerAngleZY(
T const& angleZ,
T const& angleY);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y * Z).
/// @see gtx_euler_angles
template<typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXYZ(
T const& t1,
T const& t2,
T const& t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template<typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYXZ(
T const& yaw,
T const& pitch,
T const& roll);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z * X).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXZX(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y * X).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXYX(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Y).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYXY(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z * Y).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYZY(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y * Z).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZYZ(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X * Z).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZXZ(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z * Y).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleXZY(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z * X).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleYZX(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y * X).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZYX(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X * Y).
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZXY(
T const & t1,
T const & t2,
T const & t3);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template<typename T>
GLM_FUNC_DECL mat<4, 4, 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 mat<2, 2, 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 mat<3, 3, 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, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> orientate3(vec<3, T, Q> const& angles);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z).
/// @see gtx_euler_angles
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> orientate4(vec<3, T, Q> const& angles);
/// Extracts the (X * Y * Z) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template<typename T>
GLM_FUNC_DECL void extractEulerAngleXYZ(mat<4, 4, T, defaultp> const& M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Y * X * Z) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleYXZ(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (X * Z * X) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleXZX(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (X * Y * X) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleXYX(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Y * X * Y) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleYXY(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Y * Z * Y) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleYZY(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Z * Y * Z) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleZYZ(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Z * X * Z) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleZXZ(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (X * Z * Y) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleXZY(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Y * Z * X) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleYZX(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Z * Y * X) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleZYX(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// Extracts the (Z * X * Y) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL void extractEulerAngleZXY(mat<4, 4, T, defaultp> const & M,
T & t1,
T & t2,
T & t3);
/// @}
}//namespace glm
#include "euler_angles.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_major_storage.hpp | .hpp | 3,861 | 120 | /// @ref gtx_matrix_major_storage
/// @file glm/gtx/matrix_major_storage.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_matrix_major_storage GLM_GTX_matrix_major_storage
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_major_storage.hpp> to use the features of this extension.
///
/// Build matrices with specific matrix order, row or column
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_major_storage is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !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, qualifier Q>
GLM_FUNC_DECL mat<2, 2, T, Q> rowMajor2(
vec<2, T, Q> const& v1,
vec<2, T, Q> const& v2);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 2, T, Q> rowMajor2(
mat<2, 2, T, Q> const& m);
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> rowMajor3(
vec<3, T, Q> const& v1,
vec<3, T, Q> const& v2,
vec<3, T, Q> const& v3);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> rowMajor3(
mat<3, 3, T, Q> const& m);
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> rowMajor4(
vec<4, T, Q> const& v1,
vec<4, T, Q> const& v2,
vec<4, T, Q> const& v3,
vec<4, T, Q> const& v4);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> rowMajor4(
mat<4, 4, T, Q> const& m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 2, T, Q> colMajor2(
vec<2, T, Q> const& v1,
vec<2, T, Q> const& v2);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 2, T, Q> colMajor2(
mat<2, 2, T, Q> const& m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> colMajor3(
vec<3, T, Q> const& v1,
vec<3, T, Q> const& v2,
vec<3, T, Q> const& v3);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> colMajor3(
mat<3, 3, T, Q> const& m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> colMajor4(
vec<4, T, Q> const& v1,
vec<4, T, Q> const& v2,
vec<4, T, Q> const& v3,
vec<4, T, Q> const& v4);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> colMajor4(
mat<4, 4, T, Q> const& m);
/// @}
}//namespace glm
#include "matrix_major_storage.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/color_encoding.hpp | .hpp | 1,482 | 51 | /// @ref gtx_color_encoding
/// @file glm/gtx/color_encoding.hpp
///
/// @see core (dependence)
/// @see gtx_color_encoding (dependence)
///
/// @defgroup gtx_color_encoding GLM_GTX_color_encoding
/// @ingroup gtx
///
/// Include <glm/gtx/color_encoding.hpp> to use the features of this extension.
///
/// @brief Allow to perform bit operations on integer values
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#include "../vec3.hpp"
#include <limits>
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTC_color_encoding extension included")
#endif
namespace glm
{
/// @addtogroup gtx_color_encoding
/// @{
/// Convert a linear sRGB color to D65 YUV.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> convertLinearSRGBToD65XYZ(vec<3, T, Q> const& ColorLinearSRGB);
/// Convert a linear sRGB color to D50 YUV.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> convertLinearSRGBToD50XYZ(vec<3, T, Q> const& ColorLinearSRGB);
/// Convert a D65 YUV color to linear sRGB.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> convertD65XYZToLinearSRGB(vec<3, T, Q> const& ColorD65XYZ);
/// Convert a D65 YUV color to D50 YUV.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> convertD65XYZToD50XYZ(vec<3, T, Q> const& ColorD65XYZ);
/// @}
} //namespace glm
#include "color_encoding.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/polar_coordinates.hpp | .hpp | 1,362 | 49 | /// @ref gtx_polar_coordinates
/// @file glm/gtx/polar_coordinates.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates
/// @ingroup gtx
///
/// Include <glm/gtx/polar_coordinates.hpp> to use the features of this extension.
///
/// Conversion from Euclidean space to polar space and revert.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_polar_coordinates is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !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, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> polar(
vec<3, T, Q> const& euclidean);
/// Convert Polar to Euclidean coordinates.
///
/// @see gtx_polar_coordinates
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> euclidean(
vec<2, T, Q> const& polar);
/// @}
}//namespace glm
#include "polar_coordinates.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/quaternion.hpp | .hpp | 4,701 | 175 | /// @ref gtx_quaternion
/// @file glm/gtx/quaternion.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_quaternion GLM_GTX_quaternion
/// @ingroup gtx
///
/// Include <glm/gtx/quaternion.hpp> to use the features of this extension.
///
/// Extented quaternion types and functions
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/constants.hpp"
#include "../gtc/quaternion.hpp"
#include "../ext/quaternion_exponential.hpp"
#include "../gtx/norm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_quaternion is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_quaternion extension included")
#endif
namespace glm
{
/// @addtogroup gtx_quaternion
/// @{
/// Create an identity quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> quat_identity();
/// Compute a cross product between a quaternion and a vector.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> cross(
qua<T, Q> const& q,
vec<3, T, Q> const& v);
//! Compute a cross product between a vector and a quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> cross(
vec<3, T, Q> const& v,
qua<T, Q> 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, qualifier Q>
GLM_FUNC_DECL qua<T, Q> squad(
qua<T, Q> const& q1,
qua<T, Q> const& q2,
qua<T, Q> const& s1,
qua<T, Q> const& s2,
T const& h);
//! Returns an intermediate control point for squad interpolation.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> intermediate(
qua<T, Q> const& prev,
qua<T, Q> const& curr,
qua<T, Q> const& next);
//! Returns quarternion square root.
///
/// @see gtx_quaternion
//template<typename T, qualifier Q>
//qua<T, Q> sqrt(
// qua<T, Q> const& q);
//! Rotates a 3 components vector by a quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rotate(
qua<T, Q> const& q,
vec<3, T, Q> const& v);
/// Rotates a 4 components vector by a quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> rotate(
qua<T, Q> const& q,
vec<4, T, Q> const& v);
/// Extract the real component of a quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL T extractRealComponent(
qua<T, Q> const& q);
/// Converts a quaternion to a 3 * 3 matrix.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> toMat3(
qua<T, Q> const& x){return mat3_cast(x);}
/// Converts a quaternion to a 4 * 4 matrix.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> toMat4(
qua<T, Q> const& x){return mat4_cast(x);}
/// Converts a 3 * 3 matrix to a quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> toQuat(
mat<3, 3, T, Q> const& x){return quat_cast(x);}
/// Converts a 4 * 4 matrix to a quaternion.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> toQuat(
mat<4, 4, T, Q> const& x){return quat_cast(x);}
/// Quaternion interpolation using the rotation short path.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> shortMix(
qua<T, Q> const& x,
qua<T, Q> const& y,
T const& a);
/// Quaternion normalized linear interpolation.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> fastMix(
qua<T, Q> const& x,
qua<T, Q> 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, qualifier Q>
GLM_FUNC_DECL qua<T, Q> rotation(
vec<3, T, Q> const& orig,
vec<3, T, Q> const& dest);
/// Returns the squared length of x.
///
/// @see gtx_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL T length2(qua<T, Q> const& q);
/// @}
}//namespace glm
#include "quaternion.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/normal.hpp | .hpp | 1,071 | 42 | /// @ref gtx_normal
/// @file glm/gtx/normal.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_normal GLM_GTX_normal
/// @ingroup gtx
///
/// Include <glm/gtx/normal.hpp> to use the features of this extension.
///
/// Compute the normal of a triangle.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_normal is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_normal extension included")
#endif
namespace glm
{
/// @addtogroup gtx_normal
/// @{
/// Computes triangle normal from triangle points.
///
/// @see gtx_normal
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> triangleNormal(vec<3, T, Q> const& p1, vec<3, T, Q> const& p2, vec<3, T, Q> const& p3);
/// @}
}//namespace glm
#include "normal.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/fast_square_root.hpp | .hpp | 3,005 | 93 | /// @ref gtx_fast_square_root
/// @file glm/gtx/fast_square_root.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_fast_square_root GLM_GTX_fast_square_root
/// @ingroup gtx
///
/// Include <glm/gtx/fast_square_root.hpp> to use the features of this extension.
///
/// Fast but less accurate implementations of square root based functions.
/// - Sqrt optimisation based on Newton's method,
/// www.gamedev.net/community/forums/topic.asp?topic id=139956
#pragma once
// Dependency:
#include "../common.hpp"
#include "../exponential.hpp"
#include "../geometric.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_fast_square_root is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_fast_square_root extension included")
#endif
namespace glm
{
/// @addtogroup gtx_fast_square_root
/// @{
/// Faster than the common sqrt function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<typename genType>
GLM_FUNC_DECL genType fastSqrt(genType x);
/// Faster than the common sqrt function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastSqrt(vec<L, T, Q> const& x);
/// Faster than the common inversesqrt function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<typename genType>
GLM_FUNC_DECL genType fastInverseSqrt(genType x);
/// Faster than the common inversesqrt function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastInverseSqrt(vec<L, T, Q> const& x);
/// Faster than the common length function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<typename genType>
GLM_FUNC_DECL genType fastLength(genType x);
/// Faster than the common length function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T fastLength(vec<L, T, Q> const& x);
/// Faster than the common distance function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<typename genType>
GLM_FUNC_DECL genType fastDistance(genType x, genType y);
/// Faster than the common distance function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T fastDistance(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Faster than the common normalize function but less accurate.
///
/// @see gtx_fast_square_root extension.
template<typename genType>
GLM_FUNC_DECL genType fastNormalize(genType const& x);
/// @}
}// namespace glm
#include "fast_square_root.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/raw_data.hpp | .hpp | 1,274 | 52 | /// @ref gtx_raw_data
/// @file glm/gtx/raw_data.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_raw_data GLM_GTX_raw_data
/// @ingroup gtx
///
/// Include <glm/gtx/raw_data.hpp> to use the features of this extension.
///
/// Projection of a vector to other one
#pragma once
// Dependencies
#include "../ext/scalar_uint_sized.hpp"
#include "../detail/setup.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_raw_data is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_raw_data extension included")
#endif
namespace glm
{
/// @addtogroup gtx_raw_data
/// @{
//! Type for byte numbers.
//! From GLM_GTX_raw_data extension.
typedef detail::uint8 byte;
//! Type for word numbers.
//! From GLM_GTX_raw_data extension.
typedef detail::uint16 word;
//! Type for dword numbers.
//! From GLM_GTX_raw_data extension.
typedef detail::uint32 dword;
//! Type for qword numbers.
//! From GLM_GTX_raw_data extension.
typedef detail::uint64 qword;
/// @}
}// namespace glm
#include "raw_data.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/scalar_relational.hpp | .hpp | 905 | 37 | /// @ref gtx_scalar_relational
/// @file glm/gtx/scalar_relational.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_scalar_relational GLM_GTX_scalar_relational
/// @ingroup gtx
///
/// Include <glm/gtx/scalar_relational.hpp> to use the features of this extension.
///
/// Extend a position from a source to a position at a defined length.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_extend is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_extend extension included")
#endif
namespace glm
{
/// @addtogroup gtx_scalar_relational
/// @{
/// @}
}//namespace glm
#include "scalar_relational.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/common.hpp | .hpp | 3,172 | 77 | /// @ref gtx_common
/// @file glm/gtx/common.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_common GLM_GTX_common
/// @ingroup gtx
///
/// Include <glm/gtx/common.hpp> to use the features of this extension.
///
/// @brief Provide functions to increase the compatibility with Cg and HLSL languages
#pragma once
// Dependencies:
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../gtc/vec1.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_common is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_common extension included")
#endif
namespace glm
{
/// @addtogroup gtx_common
/// @{
/// Returns true if x is a denormalized number
/// Numbers whose absolute value is too small to be represented in the normal format are represented in an alternate, denormalized format.
/// This format is less precise but can represent values closer to zero.
///
/// @tparam genType Floating-point scalar or vector types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isnan.xml">GLSL isnan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
GLM_FUNC_DECL typename genType::bool_type isdenormal(genType const& x);
/// Similar to 'mod' but with a different rounding and integer support.
/// Returns 'x - y * trunc(x/y)' instead of 'x - y * floor(x/y)'
///
/// @see <a href="http://stackoverflow.com/questions/7610631/glsl-mod-vs-hlsl-fmod">GLSL mod vs HLSL fmod</a>
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fmod(vec<L, T, Q> const& v);
/// Returns whether vector components values are within an interval. A open interval excludes its endpoints, and is denoted with square brackets.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template <length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
/// Returns whether vector components values are within an interval. A closed interval includes its endpoints, and is denoted with square brackets.
///
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template <length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
/// @}
}//namespace glm
#include "common.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/mixed_product.hpp | .hpp | 1,081 | 42 | /// @ref gtx_mixed_product
/// @file glm/gtx/mixed_product.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_mixed_product GLM_GTX_mixed_producte
/// @ingroup gtx
///
/// Include <glm/gtx/mixed_product.hpp> to use the features of this extension.
///
/// Mixed product of 3 vectors.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_mixed_product is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_mixed_product extension included")
#endif
namespace glm
{
/// @addtogroup gtx_mixed_product
/// @{
/// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension)
template<typename T, qualifier Q>
GLM_FUNC_DECL T mixedProduct(
vec<3, T, Q> const& v1,
vec<3, T, Q> const& v2,
vec<3, T, Q> const& v3);
/// @}
}// namespace glm
#include "mixed_product.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/functions.hpp | .hpp | 1,099 | 53 | /// @ref gtx_functions
/// @file glm/gtx/functions.hpp
///
/// @see core (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtx_functions GLM_GTX_functions
/// @ingroup gtx
///
/// Include <glm/gtx/functions.hpp> to use the features of this extension.
///
/// List of useful common functions.
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#include "../detail/type_vec2.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_functions extension included")
#endif
namespace glm
{
/// @addtogroup gtx_functions
/// @{
/// 1D gauss function
///
/// @see gtc_epsilon
template<typename T>
GLM_FUNC_DECL T gauss(
T x,
T ExpectedValue,
T StandardDeviation);
/// 2D gauss function
///
/// @see gtc_epsilon
template<typename T, qualifier Q>
GLM_FUNC_DECL T gauss(
vec<2, T, Q> const& Coord,
vec<2, T, Q> const& ExpectedValue,
vec<2, T, Q> const& StandardDeviation);
/// @}
}//namespace glm
#include "functions.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/exterior_product.hpp | .hpp | 1,131 | 42 | /// @ref gtx_exterior_product
/// @file glm/gtx/exterior_product.hpp
///
/// @see core (dependence)
/// @see gtx_exterior_product (dependence)
///
/// @defgroup gtx_exterior_product GLM_GTX_exterior_product
/// @ingroup gtx
///
/// Include <glm/gtx/exterior_product.hpp> to use the features of this extension.
///
/// @brief Allow to perform bit operations on integer values
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_exterior_product extension included")
#endif
namespace glm
{
/// @addtogroup gtx_exterior_product
/// @{
/// Returns the cross product of x and y.
///
/// @tparam T Floating-point scalar types
/// @tparam Q Value from qualifier enum
///
/// @see <a href="https://en.wikipedia.org/wiki/Exterior_algebra#Cross_and_triple_products">Exterior product</a>
template<typename T, qualifier Q>
GLM_FUNC_DECL T cross(vec<2, T, Q> const& v, vec<2, T, Q> const& u);
/// @}
} //namespace glm
#include "exterior_product.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/dual_quaternion.hpp | .hpp | 9,717 | 275 | /// @ref gtx_dual_quaternion
/// @file glm/gtx/dual_quaternion.hpp
/// @author Maksim Vorobiev (msomeone@gmail.com)
///
/// @see core (dependence)
/// @see gtc_constants (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtx_dual_quaternion GLM_GTX_dual_quaternion
/// @ingroup gtx
///
/// Include <glm/gtx/dual_quaternion.hpp> to use the features of this extension.
///
/// Defines a templated dual-quaternion type and several dual-quaternion operations.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/constants.hpp"
#include "../gtc/quaternion.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_dual_quaternion is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_dual_quaternion extension included")
#endif
namespace glm
{
/// @addtogroup gtx_dual_quaternion
/// @{
template<typename T, qualifier Q = defaultp>
struct tdualquat
{
// -- Implementation detail --
typedef T value_type;
typedef qua<T, Q> part_type;
// -- Data --
qua<T, Q> real, dual;
// -- Component accesses --
typedef length_t length_type;
/// Return the count of components of a dual quaternion
GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;}
GLM_FUNC_DECL part_type & operator[](length_type i);
GLM_FUNC_DECL part_type const& operator[](length_type i) const;
// -- Implicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT;
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, Q> const& d) GLM_DEFAULT;
template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const& d);
// -- Explicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real);
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& orientation, vec<3, T, Q> const& translation);
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real, qua<T, Q> const& dual);
// -- Conversion constructors --
template<typename U, qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tdualquat(tdualquat<U, P> const& q);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<2, 4, T, Q> const& holder_mat);
GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<3, 4, T, Q> const& aug_mat);
// -- Unary arithmetic operators --
GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<T, Q> const& m) GLM_DEFAULT;
template<typename U>
GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<U, Q> const& m);
template<typename U>
GLM_FUNC_DECL tdualquat<T, Q> & operator*=(U s);
template<typename U>
GLM_FUNC_DECL tdualquat<T, Q> & operator/=(U s);
};
// -- Unary bit operators --
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q);
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator-(tdualquat<T, Q> const& q);
// -- Binary operators --
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p);
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p);
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> operator*(tdualquat<T, Q> const& q, vec<3, T, Q> const& v);
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v, tdualquat<T, Q> const& q);
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> operator*(tdualquat<T, Q> const& q, vec<4, T, Q> const& v);
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q> const& v, tdualquat<T, Q> const& q);
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, T const& s);
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator*(T const& s, tdualquat<T, Q> const& q);
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> operator/(tdualquat<T, Q> const& q, T const& s);
// -- Boolean operators --
template<typename T, qualifier Q>
GLM_FUNC_DECL bool operator==(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2);
template<typename T, qualifier Q>
GLM_FUNC_DECL bool operator!=(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2);
/// Creates an identity dual quaternion.
///
/// @see gtx_dual_quaternion
template <typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> dual_quat_identity();
/// Returns the normalized quaternion.
///
/// @see gtx_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> normalize(tdualquat<T, Q> const& q);
/// Returns the linear interpolation of two dual quaternion.
///
/// @see gtc_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> lerp(tdualquat<T, Q> const& x, tdualquat<T, Q> const& y, T const& a);
/// Returns the q inverse.
///
/// @see gtx_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> inverse(tdualquat<T, Q> const& q);
/// Converts a quaternion to a 2 * 4 matrix.
///
/// @see gtx_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<2, 4, T, Q> mat2x4_cast(tdualquat<T, Q> const& x);
/// Converts a quaternion to a 3 * 4 matrix.
///
/// @see gtx_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 4, T, Q> mat3x4_cast(tdualquat<T, Q> const& x);
/// Converts a 2 * 4 matrix (matrix which holds real and dual parts) to a quaternion.
///
/// @see gtx_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<2, 4, T, Q> const& x);
/// Converts a 3 * 4 matrix (augmented matrix rotation + translation) to a quaternion.
///
/// @see gtx_dual_quaternion
template<typename T, qualifier Q>
GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<3, 4, T, Q> const& x);
/// Dual-quaternion of low single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, lowp> lowp_dualquat;
/// Dual-quaternion of medium single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, mediump> mediump_dualquat;
/// Dual-quaternion of high single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, highp> highp_dualquat;
/// Dual-quaternion of low single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, lowp> lowp_fdualquat;
/// Dual-quaternion of medium single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, mediump> mediump_fdualquat;
/// Dual-quaternion of high single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<float, highp> highp_fdualquat;
/// Dual-quaternion of low double-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<double, lowp> lowp_ddualquat;
/// Dual-quaternion of medium double-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<double, mediump> mediump_ddualquat;
/// Dual-quaternion of high double-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef tdualquat<double, highp> highp_ddualquat;
#if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
/// Dual-quaternion of floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef highp_fdualquat dualquat;
/// Dual-quaternion of single-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef highp_fdualquat fdualquat;
#elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
typedef highp_fdualquat dualquat;
typedef highp_fdualquat fdualquat;
#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
typedef mediump_fdualquat dualquat;
typedef mediump_fdualquat fdualquat;
#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
typedef lowp_fdualquat dualquat;
typedef lowp_fdualquat fdualquat;
#else
# error "GLM error: multiple default precision requested for single-precision floating-point types"
#endif
#if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
/// Dual-quaternion of default double-qualifier floating-point numbers.
///
/// @see gtx_dual_quaternion
typedef highp_ddualquat ddualquat;
#elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
typedef highp_ddualquat ddualquat;
#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE))
typedef mediump_ddualquat ddualquat;
#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE))
typedef lowp_ddualquat ddualquat;
#else
# error "GLM error: Multiple default precision requested for double-precision floating-point types"
#endif
/// @}
} //namespace glm
#include "dual_quaternion.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/spline.hpp | .hpp | 1,625 | 66 | /// @ref gtx_spline
/// @file glm/gtx/spline.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_spline GLM_GTX_spline
/// @ingroup gtx
///
/// Include <glm/gtx/spline.hpp> to use the features of this extension.
///
/// Spline functions
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/optimum_pow.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_spline is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_spline extension included")
#endif
namespace glm
{
/// @addtogroup gtx_spline
/// @{
/// Return a point from a catmull rom curve.
/// @see gtx_spline extension.
template<typename genType>
GLM_FUNC_DECL genType catmullRom(
genType const& v1,
genType const& v2,
genType const& v3,
genType const& v4,
typename genType::value_type const& s);
/// Return a point from a hermite curve.
/// @see gtx_spline extension.
template<typename genType>
GLM_FUNC_DECL genType hermite(
genType const& v1,
genType const& t1,
genType const& v2,
genType const& t2,
typename genType::value_type const& s);
/// Return a point from a cubic curve.
/// @see gtx_spline extension.
template<typename genType>
GLM_FUNC_DECL genType cubic(
genType const& v1,
genType const& v2,
genType const& v3,
genType const& v4,
typename genType::value_type const& s);
/// @}
}//namespace glm
#include "spline.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_transform_2d.hpp | .hpp | 2,589 | 82 | /// @ref gtx_matrix_transform_2d
/// @file glm/gtx/matrix_transform_2d.hpp
/// @author Miguel Ángel Pérez Martínez
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_transform_2d GLM_GTX_matrix_transform_2d
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_transform_2d.hpp> to use the features of this extension.
///
/// Defines functions that generate common 2d transformation matrices.
#pragma once
// Dependency:
#include "../mat3x3.hpp"
#include "../vec2.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_transform_2d is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_matrix_transform_2d extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_transform_2d
/// @{
/// Builds a translation 3 * 3 matrix created from a vector of 2 components.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param v Coordinates of a translation vector.
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> translate(
mat<3, 3, T, Q> const& m,
vec<2, T, Q> const& v);
/// Builds a rotation 3 * 3 matrix created from an angle.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param angle Rotation angle expressed in radians.
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> rotate(
mat<3, 3, T, Q> const& m,
T angle);
/// Builds a scale 3 * 3 matrix created from a vector of 2 components.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param v Coordinates of a scale vector.
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> scale(
mat<3, 3, T, Q> const& m,
vec<2, T, Q> const& v);
/// Builds an horizontal (parallel to the x axis) shear 3 * 3 matrix.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param y Shear factor.
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> shearX(
mat<3, 3, T, Q> const& m,
T y);
/// Builds a vertical (parallel to the y axis) shear 3 * 3 matrix.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param x Shear factor.
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> shearY(
mat<3, 3, T, Q> const& m,
T x);
/// @}
}//namespace glm
#include "matrix_transform_2d.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/fast_exponential.hpp | .hpp | 3,193 | 96 | /// @ref gtx_fast_exponential
/// @file glm/gtx/fast_exponential.hpp
///
/// @see core (dependence)
/// @see gtx_half_float (dependence)
///
/// @defgroup gtx_fast_exponential GLM_GTX_fast_exponential
/// @ingroup gtx
///
/// Include <glm/gtx/fast_exponential.hpp> to use the features of this extension.
///
/// Fast but less accurate implementations of exponential based functions.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_fast_exponential is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_fast_exponential extension included")
#endif
namespace glm
{
/// @addtogroup gtx_fast_exponential
/// @{
/// Faster than the common pow function but less accurate.
/// @see gtx_fast_exponential
template<typename genType>
GLM_FUNC_DECL genType fastPow(genType x, genType y);
/// Faster than the common pow function but less accurate.
/// @see gtx_fast_exponential
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastPow(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Faster than the common pow function but less accurate.
/// @see gtx_fast_exponential
template<typename genTypeT, typename genTypeU>
GLM_FUNC_DECL genTypeT fastPow(genTypeT x, genTypeU y);
/// Faster than the common pow function but less accurate.
/// @see gtx_fast_exponential
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastPow(vec<L, T, Q> const& x);
/// Faster than the common exp function but less accurate.
/// @see gtx_fast_exponential
template<typename T>
GLM_FUNC_DECL T fastExp(T x);
/// Faster than the common exp function but less accurate.
/// @see gtx_fast_exponential
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastExp(vec<L, T, Q> const& x);
/// Faster than the common log function but less accurate.
/// @see gtx_fast_exponential
template<typename T>
GLM_FUNC_DECL T fastLog(T x);
/// Faster than the common exp2 function but less accurate.
/// @see gtx_fast_exponential
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastLog(vec<L, T, Q> const& x);
/// Faster than the common exp2 function but less accurate.
/// @see gtx_fast_exponential
template<typename T>
GLM_FUNC_DECL T fastExp2(T x);
/// Faster than the common exp2 function but less accurate.
/// @see gtx_fast_exponential
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastExp2(vec<L, T, Q> const& x);
/// Faster than the common log2 function but less accurate.
/// @see gtx_fast_exponential
template<typename T>
GLM_FUNC_DECL T fastLog2(T x);
/// Faster than the common log2 function but less accurate.
/// @see gtx_fast_exponential
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> fastLog2(vec<L, T, Q> const& x);
/// @}
}//namespace glm
#include "fast_exponential.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/transform.hpp | .hpp | 1,725 | 61 | /// @ref gtx_transform
/// @file glm/gtx/transform.hpp
///
/// @see core (dependence)
/// @see gtc_matrix_transform (dependence)
/// @see gtx_transform
/// @see gtx_transform2
///
/// @defgroup gtx_transform GLM_GTX_transform
/// @ingroup gtx
///
/// Include <glm/gtx/transform.hpp> to use the features of this extension.
///
/// Add transformation matrices
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/matrix_transform.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_transform is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_transform extension included")
#endif
namespace glm
{
/// @addtogroup gtx_transform
/// @{
/// Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars.
/// @see gtc_matrix_transform
/// @see gtx_transform
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> translate(
vec<3, T, Q> const& v);
/// Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in radians.
/// @see gtc_matrix_transform
/// @see gtx_transform
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> rotate(
T angle,
vec<3, T, Q> const& v);
/// Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components.
/// @see gtc_matrix_transform
/// @see gtx_transform
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> scale(
vec<3, T, Q> const& v);
/// @}
}// namespace glm
#include "transform.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/optimum_pow.hpp | .hpp | 1,341 | 55 | /// @ref gtx_optimum_pow
/// @file glm/gtx/optimum_pow.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_optimum_pow GLM_GTX_optimum_pow
/// @ingroup gtx
///
/// Include <glm/gtx/optimum_pow.hpp> to use the features of this extension.
///
/// Integer exponentiation of power functions.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_optimum_pow is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_optimum_pow extension included")
#endif
namespace glm{
namespace gtx
{
/// @addtogroup gtx_optimum_pow
/// @{
/// Returns x raised to the power of 2.
///
/// @see gtx_optimum_pow
template<typename genType>
GLM_FUNC_DECL genType pow2(genType const& x);
/// Returns x raised to the power of 3.
///
/// @see gtx_optimum_pow
template<typename genType>
GLM_FUNC_DECL genType pow3(genType const& x);
/// Returns x raised to the power of 4.
///
/// @see gtx_optimum_pow
template<typename genType>
GLM_FUNC_DECL genType pow4(genType const& x);
/// @}
}//namespace gtx
}//namespace glm
#include "optimum_pow.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/transform2.hpp | .hpp | 3,506 | 90 | /// @ref gtx_transform2
/// @file glm/gtx/transform2.hpp
///
/// @see core (dependence)
/// @see gtx_transform (dependence)
///
/// @defgroup gtx_transform2 GLM_GTX_transform2
/// @ingroup gtx
///
/// Include <glm/gtx/transform2.hpp> to use the features of this extension.
///
/// Add extra transformation matrices
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/transform.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_transform2 is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_transform2 extension included")
#endif
namespace glm
{
/// @addtogroup gtx_transform2
/// @{
//! Transforms a matrix with a shearing on X axis.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> shearX2D(mat<3, 3, T, Q> const& m, T y);
//! Transforms a matrix with a shearing on Y axis.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> shearY2D(mat<3, 3, T, Q> const& m, T x);
//! Transforms a matrix with a shearing on X axis
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> shearX3D(mat<4, 4, T, Q> const& m, T y, T z);
//! Transforms a matrix with a shearing on Y axis.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> shearY3D(mat<4, 4, T, Q> const& m, T x, T z);
//! Transforms a matrix with a shearing on Z axis.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> shearZ3D(mat<4, 4, T, Q> const& m, T x, T y);
//template<typename T> GLM_FUNC_QUALIFIER mat<4, 4, T, Q> shear(const mat<4, 4, T, Q> & m, shearPlane, planePoint, angle)
// Identity + tan(angle) * cross(Normal, OnPlaneVector) 0
// - dot(PointOnPlane, normal) * OnPlaneVector 1
// Reflect functions seem to don't work
//template<typename T> mat<3, 3, T, Q> reflect2D(const mat<3, 3, T, Q> & m, const vec<3, T, Q>& normal){return reflect2DGTX(m, normal);} //!< \brief Build a reflection matrix (from GLM_GTX_transform2 extension)
//template<typename T> mat<4, 4, T, Q> reflect3D(const mat<4, 4, T, Q> & m, const vec<3, T, Q>& normal){return reflect3DGTX(m, normal);} //!< \brief Build a reflection matrix (from GLM_GTX_transform2 extension)
//! Build planar projection matrix along normal axis.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> proj2D(mat<3, 3, T, Q> const& m, vec<3, T, Q> const& normal);
//! Build planar projection matrix along normal axis.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> proj3D(mat<4, 4, T, Q> const & m, vec<3, T, Q> const& normal);
//! Build a scale bias matrix.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> scaleBias(T scale, T bias);
//! Build a scale bias matrix.
//! From GLM_GTX_transform2 extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> scaleBias(mat<4, 4, T, Q> const& m, T scale, T bias);
/// @}
}// namespace glm
#include "transform2.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/rotate_vector.hpp | .hpp | 3,693 | 124 | /// @ref gtx_rotate_vector
/// @file glm/gtx/rotate_vector.hpp
///
/// @see core (dependence)
/// @see gtx_transform (dependence)
///
/// @defgroup gtx_rotate_vector GLM_GTX_rotate_vector
/// @ingroup gtx
///
/// Include <glm/gtx/rotate_vector.hpp> to use the features of this extension.
///
/// Function to directly rotate a vector
#pragma once
// Dependency:
#include "../gtx/transform.hpp"
#include "../gtc/epsilon.hpp"
#include "../ext/vector_relational.hpp"
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_rotate_vector is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_rotate_vector extension included")
#endif
namespace glm
{
/// @addtogroup gtx_rotate_vector
/// @{
/// Returns Spherical interpolation between two vectors
///
/// @param x A first vector
/// @param y A second vector
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
///
/// @see gtx_rotate_vector
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> slerp(
vec<3, T, Q> const& x,
vec<3, T, Q> const& y,
T const& a);
//! Rotate a two dimensional vector.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<2, T, Q> rotate(
vec<2, T, Q> const& v,
T const& angle);
//! Rotate a three dimensional vector around an axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rotate(
vec<3, T, Q> const& v,
T const& angle,
vec<3, T, Q> const& normal);
//! Rotate a four dimensional vector around an axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> rotate(
vec<4, T, Q> const& v,
T const& angle,
vec<3, T, Q> const& normal);
//! Rotate a three dimensional vector around the X axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rotateX(
vec<3, T, Q> const& v,
T const& angle);
//! Rotate a three dimensional vector around the Y axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rotateY(
vec<3, T, Q> const& v,
T const& angle);
//! Rotate a three dimensional vector around the Z axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rotateZ(
vec<3, T, Q> const& v,
T const& angle);
//! Rotate a four dimensional vector around the X axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> rotateX(
vec<4, T, Q> const& v,
T const& angle);
//! Rotate a four dimensional vector around the Y axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> rotateY(
vec<4, T, Q> const& v,
T const& angle);
//! Rotate a four dimensional vector around the Z axis.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> rotateZ(
vec<4, T, Q> const& v,
T const& angle);
//! Build a rotation matrix from a normal and a up vector.
//! From GLM_GTX_rotate_vector extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> orientation(
vec<3, T, Q> const& Normal,
vec<3, T, Q> const& Up);
/// @}
}//namespace glm
#include "rotate_vector.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/color_space.hpp | .hpp | 2,025 | 73 | /// @ref gtx_color_space
/// @file glm/gtx/color_space.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_color_space GLM_GTX_color_space
/// @ingroup gtx
///
/// Include <glm/gtx/color_space.hpp> to use the features of this extension.
///
/// Related to RGB to HSV conversions and operations.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_color_space is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_color_space extension included")
#endif
namespace glm
{
/// @addtogroup gtx_color_space
/// @{
/// Converts a color from HSV color space to its color in RGB color space.
/// @see gtx_color_space
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rgbColor(
vec<3, T, Q> const& hsvValue);
/// Converts a color from RGB color space to its color in HSV color space.
/// @see gtx_color_space
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> hsvColor(
vec<3, T, Q> const& rgbValue);
/// Build a saturation matrix.
/// @see gtx_color_space
template<typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> saturation(
T const s);
/// Modify the saturation of a color.
/// @see gtx_color_space
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> saturation(
T const s,
vec<3, T, Q> const& color);
/// Modify the saturation of a color.
/// @see gtx_color_space
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<4, T, Q> saturation(
T const s,
vec<4, T, Q> const& color);
/// Compute color luminosity associating ratios (0.33, 0.59, 0.11) to RGB canals.
/// @see gtx_color_space
template<typename T, qualifier Q>
GLM_FUNC_DECL T luminosity(
vec<3, T, Q> const& color);
/// @}
}//namespace glm
#include "color_space.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/fast_trigonometry.hpp | .hpp | 2,454 | 80 | /// @ref gtx_fast_trigonometry
/// @file glm/gtx/fast_trigonometry.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_fast_trigonometry GLM_GTX_fast_trigonometry
/// @ingroup gtx
///
/// Include <glm/gtx/fast_trigonometry.hpp> to use the features of this extension.
///
/// Fast but less accurate implementations of trigonometric functions.
#pragma once
// Dependency:
#include "../gtc/constants.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_fast_trigonometry is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_fast_trigonometry extension included")
#endif
namespace glm
{
/// @addtogroup gtx_fast_trigonometry
/// @{
/// Wrap an angle to [0 2pi[
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T wrapAngle(T angle);
/// Faster than the common sin function but less accurate.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastSin(T angle);
/// Faster than the common cos function but less accurate.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastCos(T angle);
/// Faster than the common tan function but less accurate.
/// Defined between -2pi and 2pi.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastTan(T angle);
/// Faster than the common asin function but less accurate.
/// Defined between -2pi and 2pi.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastAsin(T angle);
/// Faster than the common acos function but less accurate.
/// Defined between -2pi and 2pi.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastAcos(T angle);
/// Faster than the common atan function but less accurate.
/// Defined between -2pi and 2pi.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastAtan(T y, T x);
/// Faster than the common atan function but less accurate.
/// Defined between -2pi and 2pi.
/// From GLM_GTX_fast_trigonometry extension.
template<typename T>
GLM_FUNC_DECL T fastAtan(T angle);
/// @}
}//namespace glm
#include "fast_trigonometry.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/io.hpp | .hpp | 7,343 | 202 | /// @ref gtx_io
/// @file glm/gtx/io.hpp
/// @author Jan P Springer (regnirpsj@gmail.com)
///
/// @see core (dependence)
/// @see gtc_matrix_access (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtx_io GLM_GTX_io
/// @ingroup gtx
///
/// Include <glm/gtx/io.hpp> to use the features of this extension.
///
/// std::[w]ostream support for glm types
///
/// std::[w]ostream support for glm types + qualifier/width/etc. manipulators
/// based on howard hinnant's std::chrono io proposal
/// [http://home.roadrunner.com/~hinnant/bloomington/chrono_io.html]
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/quaternion.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_io is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_io extension included")
#endif
#include <iosfwd> // std::basic_ostream<> (fwd)
#include <locale> // std::locale, std::locale::facet, std::locale::id
#include <utility> // std::pair<>
namespace glm
{
/// @addtogroup gtx_io
/// @{
namespace io
{
enum order_type { column_major, row_major};
template<typename CTy>
class format_punct : public std::locale::facet
{
typedef CTy char_type;
public:
static std::locale::id id;
bool formatted;
unsigned precision;
unsigned width;
char_type separator;
char_type delim_left;
char_type delim_right;
char_type space;
char_type newline;
order_type order;
GLM_FUNC_DECL explicit format_punct(size_t a = 0);
GLM_FUNC_DECL explicit format_punct(format_punct const&);
};
template<typename CTy, typename CTr = std::char_traits<CTy> >
class basic_state_saver {
public:
GLM_FUNC_DECL explicit basic_state_saver(std::basic_ios<CTy,CTr>&);
GLM_FUNC_DECL ~basic_state_saver();
private:
typedef ::std::basic_ios<CTy,CTr> state_type;
typedef typename state_type::char_type char_type;
typedef ::std::ios_base::fmtflags flags_type;
typedef ::std::streamsize streamsize_type;
typedef ::std::locale const locale_type;
state_type& state_;
flags_type flags_;
streamsize_type precision_;
streamsize_type width_;
char_type fill_;
locale_type locale_;
GLM_FUNC_DECL basic_state_saver& operator=(basic_state_saver const&);
};
typedef basic_state_saver<char> state_saver;
typedef basic_state_saver<wchar_t> wstate_saver;
template<typename CTy, typename CTr = std::char_traits<CTy> >
class basic_format_saver
{
public:
GLM_FUNC_DECL explicit basic_format_saver(std::basic_ios<CTy,CTr>&);
GLM_FUNC_DECL ~basic_format_saver();
private:
basic_state_saver<CTy> const bss_;
GLM_FUNC_DECL basic_format_saver& operator=(basic_format_saver const&);
};
typedef basic_format_saver<char> format_saver;
typedef basic_format_saver<wchar_t> wformat_saver;
struct precision
{
unsigned value;
GLM_FUNC_DECL explicit precision(unsigned);
};
struct width
{
unsigned value;
GLM_FUNC_DECL explicit width(unsigned);
};
template<typename CTy>
struct delimeter
{
CTy value[3];
GLM_FUNC_DECL explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ',');
};
struct order
{
order_type value;
GLM_FUNC_DECL explicit order(order_type);
};
// functions, inlined (inline)
template<typename FTy, typename CTy, typename CTr>
FTy const& get_facet(std::basic_ios<CTy,CTr>&);
template<typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&);
template<typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& unformattet(std::basic_ios<CTy,CTr>&);
template<typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&);
template<typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, width const&);
template<typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&);
template<typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&);
}//namespace io
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, qua<T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<1, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<2, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<3, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, vec<4, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 2, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 3, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<2, 4, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 2, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 3, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<3, 4, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 2, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 3, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, mat<4, 4, T, Q> const&);
template<typename CTy, typename CTr, typename T, qualifier Q>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr> &,
std::pair<mat<4, 4, T, Q> const, mat<4, 4, T, Q> const> const&);
/// @}
}//namespace glm
#include "io.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/handed_coordinate_space.hpp | .hpp | 1,544 | 51 | /// @ref gtx_handed_coordinate_space
/// @file glm/gtx/handed_coordinate_space.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_handed_coordinate_space GLM_GTX_handed_coordinate_space
/// @ingroup gtx
///
/// Include <glm/gtx/handed_coordinate_system.hpp> to use the features of this extension.
///
/// To know if a set of three basis vectors defines a right or left-handed coordinate system.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_handed_coordinate_space is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_handed_coordinate_space extension included")
#endif
namespace glm
{
/// @addtogroup gtx_handed_coordinate_space
/// @{
//! Return if a trihedron right handed or not.
//! From GLM_GTX_handed_coordinate_space extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool rightHanded(
vec<3, T, Q> const& tangent,
vec<3, T, Q> const& binormal,
vec<3, T, Q> const& normal);
//! Return if a trihedron left handed or not.
//! From GLM_GTX_handed_coordinate_space extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool leftHanded(
vec<3, T, Q> const& tangent,
vec<3, T, Q> const& binormal,
vec<3, T, Q> const& normal);
/// @}
}// namespace glm
#include "handed_coordinate_space.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/type_aligned.hpp | .hpp | 34,252 | 983 | /// @ref gtx_type_aligned
/// @file glm/gtx/type_aligned.hpp
///
/// @see core (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtx_type_aligned GLM_GTX_type_aligned
/// @ingroup gtx
///
/// Include <glm/gtx/type_aligned.hpp> to use the features of this extension.
///
/// Defines aligned types.
#pragma once
// Dependency:
#include "../gtc/type_precision.hpp"
#include "../gtc/quaternion.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_type_aligned is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_type_aligned extension included")
#endif
namespace glm
{
///////////////////////////
// Signed int vector types
/// @addtogroup gtx_type_aligned
/// @{
/// Low qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int8, aligned_lowp_int8, 1);
/// Low qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int16, aligned_lowp_int16, 2);
/// Low qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int32, aligned_lowp_int32, 4);
/// Low qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int64, aligned_lowp_int64, 8);
/// Low qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int8_t, aligned_lowp_int8_t, 1);
/// Low qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int16_t, aligned_lowp_int16_t, 2);
/// Low qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int32_t, aligned_lowp_int32_t, 4);
/// Low qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_int64_t, aligned_lowp_int64_t, 8);
/// Low qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_i8, aligned_lowp_i8, 1);
/// Low qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_i16, aligned_lowp_i16, 2);
/// Low qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_i32, aligned_lowp_i32, 4);
/// Low qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_i64, aligned_lowp_i64, 8);
/// Medium qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int8, aligned_mediump_int8, 1);
/// Medium qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int16, aligned_mediump_int16, 2);
/// Medium qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int32, aligned_mediump_int32, 4);
/// Medium qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int64, aligned_mediump_int64, 8);
/// Medium qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int8_t, aligned_mediump_int8_t, 1);
/// Medium qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int16_t, aligned_mediump_int16_t, 2);
/// Medium qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int32_t, aligned_mediump_int32_t, 4);
/// Medium qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_int64_t, aligned_mediump_int64_t, 8);
/// Medium qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_i8, aligned_mediump_i8, 1);
/// Medium qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_i16, aligned_mediump_i16, 2);
/// Medium qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_i32, aligned_mediump_i32, 4);
/// Medium qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_i64, aligned_mediump_i64, 8);
/// High qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int8, aligned_highp_int8, 1);
/// High qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int16, aligned_highp_int16, 2);
/// High qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int32, aligned_highp_int32, 4);
/// High qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int64, aligned_highp_int64, 8);
/// High qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int8_t, aligned_highp_int8_t, 1);
/// High qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int16_t, aligned_highp_int16_t, 2);
/// High qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int32_t, aligned_highp_int32_t, 4);
/// High qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_int64_t, aligned_highp_int64_t, 8);
/// High qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_i8, aligned_highp_i8, 1);
/// High qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_i16, aligned_highp_i16, 2);
/// High qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_i32, aligned_highp_i32, 4);
/// High qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_i64, aligned_highp_i64, 8);
/// Default qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int8, aligned_int8, 1);
/// Default qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int16, aligned_int16, 2);
/// Default qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int32, aligned_int32, 4);
/// Default qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int64, aligned_int64, 8);
/// Default qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int8_t, aligned_int8_t, 1);
/// Default qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int16_t, aligned_int16_t, 2);
/// Default qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int32_t, aligned_int32_t, 4);
/// Default qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(int64_t, aligned_int64_t, 8);
/// Default qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i8, aligned_i8, 1);
/// Default qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i16, aligned_i16, 2);
/// Default qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i32, aligned_i32, 4);
/// Default qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i64, aligned_i64, 8);
/// Default qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(ivec1, aligned_ivec1, 4);
/// Default qualifier 32 bit signed integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(ivec2, aligned_ivec2, 8);
/// Default qualifier 32 bit signed integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(ivec3, aligned_ivec3, 16);
/// Default qualifier 32 bit signed integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(ivec4, aligned_ivec4, 16);
/// Default qualifier 8 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i8vec1, aligned_i8vec1, 1);
/// Default qualifier 8 bit signed integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i8vec2, aligned_i8vec2, 2);
/// Default qualifier 8 bit signed integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i8vec3, aligned_i8vec3, 4);
/// Default qualifier 8 bit signed integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i8vec4, aligned_i8vec4, 4);
/// Default qualifier 16 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i16vec1, aligned_i16vec1, 2);
/// Default qualifier 16 bit signed integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i16vec2, aligned_i16vec2, 4);
/// Default qualifier 16 bit signed integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i16vec3, aligned_i16vec3, 8);
/// Default qualifier 16 bit signed integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i16vec4, aligned_i16vec4, 8);
/// Default qualifier 32 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i32vec1, aligned_i32vec1, 4);
/// Default qualifier 32 bit signed integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i32vec2, aligned_i32vec2, 8);
/// Default qualifier 32 bit signed integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i32vec3, aligned_i32vec3, 16);
/// Default qualifier 32 bit signed integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i32vec4, aligned_i32vec4, 16);
/// Default qualifier 64 bit signed integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i64vec1, aligned_i64vec1, 8);
/// Default qualifier 64 bit signed integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i64vec2, aligned_i64vec2, 16);
/// Default qualifier 64 bit signed integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i64vec3, aligned_i64vec3, 32);
/// Default qualifier 64 bit signed integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(i64vec4, aligned_i64vec4, 32);
/////////////////////////////
// Unsigned int vector types
/// Low qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint8, aligned_lowp_uint8, 1);
/// Low qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint16, aligned_lowp_uint16, 2);
/// Low qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint32, aligned_lowp_uint32, 4);
/// Low qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint64, aligned_lowp_uint64, 8);
/// Low qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint8_t, aligned_lowp_uint8_t, 1);
/// Low qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint16_t, aligned_lowp_uint16_t, 2);
/// Low qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint32_t, aligned_lowp_uint32_t, 4);
/// Low qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_uint64_t, aligned_lowp_uint64_t, 8);
/// Low qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_u8, aligned_lowp_u8, 1);
/// Low qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_u16, aligned_lowp_u16, 2);
/// Low qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_u32, aligned_lowp_u32, 4);
/// Low qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(lowp_u64, aligned_lowp_u64, 8);
/// Medium qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint8, aligned_mediump_uint8, 1);
/// Medium qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint16, aligned_mediump_uint16, 2);
/// Medium qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint32, aligned_mediump_uint32, 4);
/// Medium qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint64, aligned_mediump_uint64, 8);
/// Medium qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint8_t, aligned_mediump_uint8_t, 1);
/// Medium qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint16_t, aligned_mediump_uint16_t, 2);
/// Medium qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint32_t, aligned_mediump_uint32_t, 4);
/// Medium qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_uint64_t, aligned_mediump_uint64_t, 8);
/// Medium qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_u8, aligned_mediump_u8, 1);
/// Medium qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_u16, aligned_mediump_u16, 2);
/// Medium qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_u32, aligned_mediump_u32, 4);
/// Medium qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mediump_u64, aligned_mediump_u64, 8);
/// High qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint8, aligned_highp_uint8, 1);
/// High qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint16, aligned_highp_uint16, 2);
/// High qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint32, aligned_highp_uint32, 4);
/// High qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint64, aligned_highp_uint64, 8);
/// High qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint8_t, aligned_highp_uint8_t, 1);
/// High qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint16_t, aligned_highp_uint16_t, 2);
/// High qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint32_t, aligned_highp_uint32_t, 4);
/// High qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_uint64_t, aligned_highp_uint64_t, 8);
/// High qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_u8, aligned_highp_u8, 1);
/// High qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_u16, aligned_highp_u16, 2);
/// High qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_u32, aligned_highp_u32, 4);
/// High qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(highp_u64, aligned_highp_u64, 8);
/// Default qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint8, aligned_uint8, 1);
/// Default qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint16, aligned_uint16, 2);
/// Default qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint32, aligned_uint32, 4);
/// Default qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint64, aligned_uint64, 8);
/// Default qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint8_t, aligned_uint8_t, 1);
/// Default qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint16_t, aligned_uint16_t, 2);
/// Default qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint32_t, aligned_uint32_t, 4);
/// Default qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uint64_t, aligned_uint64_t, 8);
/// Default qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u8, aligned_u8, 1);
/// Default qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u16, aligned_u16, 2);
/// Default qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u32, aligned_u32, 4);
/// Default qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u64, aligned_u64, 8);
/// Default qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uvec1, aligned_uvec1, 4);
/// Default qualifier 32 bit unsigned integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uvec2, aligned_uvec2, 8);
/// Default qualifier 32 bit unsigned integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uvec3, aligned_uvec3, 16);
/// Default qualifier 32 bit unsigned integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(uvec4, aligned_uvec4, 16);
/// Default qualifier 8 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u8vec1, aligned_u8vec1, 1);
/// Default qualifier 8 bit unsigned integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u8vec2, aligned_u8vec2, 2);
/// Default qualifier 8 bit unsigned integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u8vec3, aligned_u8vec3, 4);
/// Default qualifier 8 bit unsigned integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u8vec4, aligned_u8vec4, 4);
/// Default qualifier 16 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u16vec1, aligned_u16vec1, 2);
/// Default qualifier 16 bit unsigned integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u16vec2, aligned_u16vec2, 4);
/// Default qualifier 16 bit unsigned integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u16vec3, aligned_u16vec3, 8);
/// Default qualifier 16 bit unsigned integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u16vec4, aligned_u16vec4, 8);
/// Default qualifier 32 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u32vec1, aligned_u32vec1, 4);
/// Default qualifier 32 bit unsigned integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u32vec2, aligned_u32vec2, 8);
/// Default qualifier 32 bit unsigned integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u32vec3, aligned_u32vec3, 16);
/// Default qualifier 32 bit unsigned integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u32vec4, aligned_u32vec4, 16);
/// Default qualifier 64 bit unsigned integer aligned scalar type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u64vec1, aligned_u64vec1, 8);
/// Default qualifier 64 bit unsigned integer aligned vector of 2 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u64vec2, aligned_u64vec2, 16);
/// Default qualifier 64 bit unsigned integer aligned vector of 3 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u64vec3, aligned_u64vec3, 32);
/// Default qualifier 64 bit unsigned integer aligned vector of 4 components type.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(u64vec4, aligned_u64vec4, 32);
//////////////////////
// Float vector types
/// 32 bit single-qualifier floating-point aligned scalar.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(float32, aligned_float32, 4);
/// 32 bit single-qualifier floating-point aligned scalar.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(float32_t, aligned_float32_t, 4);
/// 32 bit single-qualifier floating-point aligned scalar.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(float32, aligned_f32, 4);
# ifndef GLM_FORCE_SINGLE_ONLY
/// 64 bit double-qualifier floating-point aligned scalar.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(float64, aligned_float64, 8);
/// 64 bit double-qualifier floating-point aligned scalar.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(float64_t, aligned_float64_t, 8);
/// 64 bit double-qualifier floating-point aligned scalar.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(float64, aligned_f64, 8);
# endif//GLM_FORCE_SINGLE_ONLY
/// Single-qualifier floating-point aligned vector of 1 component.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(vec1, aligned_vec1, 4);
/// Single-qualifier floating-point aligned vector of 2 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(vec2, aligned_vec2, 8);
/// Single-qualifier floating-point aligned vector of 3 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(vec3, aligned_vec3, 16);
/// Single-qualifier floating-point aligned vector of 4 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(vec4, aligned_vec4, 16);
/// Single-qualifier floating-point aligned vector of 1 component.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fvec1, aligned_fvec1, 4);
/// Single-qualifier floating-point aligned vector of 2 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fvec2, aligned_fvec2, 8);
/// Single-qualifier floating-point aligned vector of 3 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fvec3, aligned_fvec3, 16);
/// Single-qualifier floating-point aligned vector of 4 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fvec4, aligned_fvec4, 16);
/// Single-qualifier floating-point aligned vector of 1 component.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32vec1, aligned_f32vec1, 4);
/// Single-qualifier floating-point aligned vector of 2 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32vec2, aligned_f32vec2, 8);
/// Single-qualifier floating-point aligned vector of 3 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32vec3, aligned_f32vec3, 16);
/// Single-qualifier floating-point aligned vector of 4 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32vec4, aligned_f32vec4, 16);
/// Double-qualifier floating-point aligned vector of 1 component.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(dvec1, aligned_dvec1, 8);
/// Double-qualifier floating-point aligned vector of 2 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(dvec2, aligned_dvec2, 16);
/// Double-qualifier floating-point aligned vector of 3 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(dvec3, aligned_dvec3, 32);
/// Double-qualifier floating-point aligned vector of 4 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(dvec4, aligned_dvec4, 32);
# ifndef GLM_FORCE_SINGLE_ONLY
/// Double-qualifier floating-point aligned vector of 1 component.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64vec1, aligned_f64vec1, 8);
/// Double-qualifier floating-point aligned vector of 2 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64vec2, aligned_f64vec2, 16);
/// Double-qualifier floating-point aligned vector of 3 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64vec3, aligned_f64vec3, 32);
/// Double-qualifier floating-point aligned vector of 4 components.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64vec4, aligned_f64vec4, 32);
# endif//GLM_FORCE_SINGLE_ONLY
//////////////////////
// Float matrix types
/// Single-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef detail::tmat1<f32> mat1;
/// Single-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mat2, aligned_mat2, 16);
/// Single-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mat3, aligned_mat3, 16);
/// Single-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mat4, aligned_mat4, 16);
/// Single-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef detail::tmat1x1<f32> mat1;
/// Single-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mat2x2, aligned_mat2x2, 16);
/// Single-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mat3x3, aligned_mat3x3, 16);
/// Single-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(mat4x4, aligned_mat4x4, 16);
/// Single-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef detail::tmat1x1<f32> fmat1;
/// Single-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat2x2, aligned_fmat2, 16);
/// Single-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat3x3, aligned_fmat3, 16);
/// Single-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat4x4, aligned_fmat4, 16);
/// Single-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef f32 fmat1x1;
/// Single-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat2x2, aligned_fmat2x2, 16);
/// Single-qualifier floating-point aligned 2x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat2x3, aligned_fmat2x3, 16);
/// Single-qualifier floating-point aligned 2x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat2x4, aligned_fmat2x4, 16);
/// Single-qualifier floating-point aligned 3x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat3x2, aligned_fmat3x2, 16);
/// Single-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat3x3, aligned_fmat3x3, 16);
/// Single-qualifier floating-point aligned 3x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat3x4, aligned_fmat3x4, 16);
/// Single-qualifier floating-point aligned 4x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat4x2, aligned_fmat4x2, 16);
/// Single-qualifier floating-point aligned 4x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat4x3, aligned_fmat4x3, 16);
/// Single-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(fmat4x4, aligned_fmat4x4, 16);
/// Single-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef detail::tmat1x1<f32, defaultp> f32mat1;
/// Single-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat2x2, aligned_f32mat2, 16);
/// Single-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat3x3, aligned_f32mat3, 16);
/// Single-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat4x4, aligned_f32mat4, 16);
/// Single-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef f32 f32mat1x1;
/// Single-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat2x2, aligned_f32mat2x2, 16);
/// Single-qualifier floating-point aligned 2x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat2x3, aligned_f32mat2x3, 16);
/// Single-qualifier floating-point aligned 2x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat2x4, aligned_f32mat2x4, 16);
/// Single-qualifier floating-point aligned 3x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat3x2, aligned_f32mat3x2, 16);
/// Single-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat3x3, aligned_f32mat3x3, 16);
/// Single-qualifier floating-point aligned 3x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat3x4, aligned_f32mat3x4, 16);
/// Single-qualifier floating-point aligned 4x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat4x2, aligned_f32mat4x2, 16);
/// Single-qualifier floating-point aligned 4x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat4x3, aligned_f32mat4x3, 16);
/// Single-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32mat4x4, aligned_f32mat4x4, 16);
# ifndef GLM_FORCE_SINGLE_ONLY
/// Double-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef detail::tmat1x1<f64, defaultp> f64mat1;
/// Double-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat2x2, aligned_f64mat2, 32);
/// Double-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat3x3, aligned_f64mat3, 32);
/// Double-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat4x4, aligned_f64mat4, 32);
/// Double-qualifier floating-point aligned 1x1 matrix.
/// @see gtx_type_aligned
//typedef f64 f64mat1x1;
/// Double-qualifier floating-point aligned 2x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat2x2, aligned_f64mat2x2, 32);
/// Double-qualifier floating-point aligned 2x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat2x3, aligned_f64mat2x3, 32);
/// Double-qualifier floating-point aligned 2x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat2x4, aligned_f64mat2x4, 32);
/// Double-qualifier floating-point aligned 3x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat3x2, aligned_f64mat3x2, 32);
/// Double-qualifier floating-point aligned 3x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat3x3, aligned_f64mat3x3, 32);
/// Double-qualifier floating-point aligned 3x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat3x4, aligned_f64mat3x4, 32);
/// Double-qualifier floating-point aligned 4x2 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat4x2, aligned_f64mat4x2, 32);
/// Double-qualifier floating-point aligned 4x3 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat4x3, aligned_f64mat4x3, 32);
/// Double-qualifier floating-point aligned 4x4 matrix.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64mat4x4, aligned_f64mat4x4, 32);
# endif//GLM_FORCE_SINGLE_ONLY
//////////////////////////
// Quaternion types
/// Single-qualifier floating-point aligned quaternion.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(quat, aligned_quat, 16);
/// Single-qualifier floating-point aligned quaternion.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(quat, aligned_fquat, 16);
/// Double-qualifier floating-point aligned quaternion.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(dquat, aligned_dquat, 32);
/// Single-qualifier floating-point aligned quaternion.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f32quat, aligned_f32quat, 16);
# ifndef GLM_FORCE_SINGLE_ONLY
/// Double-qualifier floating-point aligned quaternion.
/// @see gtx_type_aligned
GLM_ALIGNED_TYPEDEF(f64quat, aligned_f64quat, 32);
# endif//GLM_FORCE_SINGLE_ONLY
/// @}
}//namespace glm
#include "type_aligned.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/color_space_YCoCg.hpp | .hpp | 1,906 | 61 | /// @ref gtx_color_space_YCoCg
/// @file glm/gtx/color_space_YCoCg.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_color_space_YCoCg GLM_GTX_color_space_YCoCg
/// @ingroup gtx
///
/// Include <glm/gtx/color_space_YCoCg.hpp> to use the features of this extension.
///
/// RGB to YCoCg conversions and operations
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_color_space_YCoCg is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_color_space_YCoCg extension included")
#endif
namespace glm
{
/// @addtogroup gtx_color_space_YCoCg
/// @{
/// Convert a color from RGB color space to YCoCg color space.
/// @see gtx_color_space_YCoCg
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rgb2YCoCg(
vec<3, T, Q> const& rgbColor);
/// Convert a color from YCoCg color space to RGB color space.
/// @see gtx_color_space_YCoCg
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> YCoCg2rgb(
vec<3, T, Q> const& YCoCgColor);
/// Convert a color from RGB color space to YCoCgR color space.
/// @see "YCoCg-R: A Color Space with RGB Reversibility and Low Dynamic Range"
/// @see gtx_color_space_YCoCg
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> rgb2YCoCgR(
vec<3, T, Q> const& rgbColor);
/// Convert a color from YCoCgR color space to RGB color space.
/// @see "YCoCg-R: A Color Space with RGB Reversibility and Low Dynamic Range"
/// @see gtx_color_space_YCoCg
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> YCoCgR2rgb(
vec<3, T, Q> const& YCoCgColor);
/// @}
}//namespace glm
#include "color_space_YCoCg.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/range.hpp | .hpp | 2,283 | 99 | /// @ref gtx_range
/// @file glm/gtx/range.hpp
/// @author Joshua Moerman
///
/// @defgroup gtx_range GLM_GTX_range
/// @ingroup gtx
///
/// Include <glm/gtx/range.hpp> to use the features of this extension.
///
/// Defines begin and end for vectors and matrices. Useful for range-based for loop.
/// The range is defined over the elements, not over columns or rows (e.g. mat4 has 16 elements).
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_range is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if !GLM_HAS_RANGE_FOR
# error "GLM_GTX_range requires C++11 suppport or 'range for'"
#endif
#include "../gtc/type_ptr.hpp"
#include "../gtc/vec1.hpp"
namespace glm
{
/// @addtogroup gtx_range
/// @{
# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4100) // unreferenced formal parameter
# endif
template<typename T, qualifier Q>
inline length_t components(vec<1, T, Q> const& v)
{
return v.length();
}
template<typename T, qualifier Q>
inline length_t components(vec<2, T, Q> const& v)
{
return v.length();
}
template<typename T, qualifier Q>
inline length_t components(vec<3, T, Q> const& v)
{
return v.length();
}
template<typename T, qualifier Q>
inline length_t components(vec<4, T, Q> const& v)
{
return v.length();
}
template<typename genType>
inline length_t components(genType const& m)
{
return m.length() * m[0].length();
}
template<typename genType>
inline typename genType::value_type const * begin(genType const& v)
{
return value_ptr(v);
}
template<typename genType>
inline typename genType::value_type const * end(genType const& v)
{
return begin(v) + components(v);
}
template<typename genType>
inline typename genType::value_type * begin(genType& v)
{
return value_ptr(v);
}
template<typename genType>
inline typename genType::value_type * end(genType& v)
{
return begin(v) + components(v);
}
# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif
/// @}
}//namespace glm
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/gradient_paint.hpp | .hpp | 1,494 | 54 | /// @ref gtx_gradient_paint
/// @file glm/gtx/gradient_paint.hpp
///
/// @see core (dependence)
/// @see gtx_optimum_pow (dependence)
///
/// @defgroup gtx_gradient_paint GLM_GTX_gradient_paint
/// @ingroup gtx
///
/// Include <glm/gtx/gradient_paint.hpp> to use the features of this extension.
///
/// Functions that return the color of procedural gradient for specific coordinates.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/optimum_pow.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_gradient_paint is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_gradient_paint extension included")
#endif
namespace glm
{
/// @addtogroup gtx_gradient_paint
/// @{
/// Return a color from a radial gradient.
/// @see - gtx_gradient_paint
template<typename T, qualifier Q>
GLM_FUNC_DECL T radialGradient(
vec<2, T, Q> const& Center,
T const& Radius,
vec<2, T, Q> const& Focal,
vec<2, T, Q> const& Position);
/// Return a color from a linear gradient.
/// @see - gtx_gradient_paint
template<typename T, qualifier Q>
GLM_FUNC_DECL T linearGradient(
vec<2, T, Q> const& Point0,
vec<2, T, Q> const& Point1,
vec<2, T, Q> const& Position);
/// @}
}// namespace glm
#include "gradient_paint.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/rotate_normalized_axis.hpp | .hpp | 2,284 | 69 | /// @ref gtx_rotate_normalized_axis
/// @file glm/gtx/rotate_normalized_axis.hpp
///
/// @see core (dependence)
/// @see gtc_matrix_transform
/// @see gtc_quaternion
///
/// @defgroup gtx_rotate_normalized_axis GLM_GTX_rotate_normalized_axis
/// @ingroup gtx
///
/// Include <glm/gtx/rotate_normalized_axis.hpp> to use the features of this extension.
///
/// Quaternions and matrices rotations around normalized axis.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/epsilon.hpp"
#include "../gtc/quaternion.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_rotate_normalized_axis is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_rotate_normalized_axis extension included")
#endif
namespace glm
{
/// @addtogroup gtx_rotate_normalized_axis
/// @{
/// Builds a rotation 4 * 4 matrix created from a normalized axis and an angle.
///
/// @param m Input matrix multiplied by this rotation matrix.
/// @param angle Rotation angle expressed in radians.
/// @param axis Rotation axis, must be normalized.
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
///
/// @see gtx_rotate_normalized_axis
/// @see - rotate(T angle, T x, T y, T z)
/// @see - rotate(mat<4, 4, T, Q> const& m, T angle, T x, T y, T z)
/// @see - rotate(T angle, vec<3, T, Q> const& v)
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> rotateNormalizedAxis(
mat<4, 4, T, Q> const& m,
T const& angle,
vec<3, T, Q> const& axis);
/// Rotates a quaternion from a vector of 3 components normalized axis and an angle.
///
/// @param q Source orientation
/// @param angle Angle expressed in radians.
/// @param axis Normalized axis of the rotation, must be normalized.
///
/// @see gtx_rotate_normalized_axis
template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> rotateNormalizedAxis(
qua<T, Q> const& q,
T const& angle,
vec<3, T, Q> const& axis);
/// @}
}//namespace glm
#include "rotate_normalized_axis.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/texture.hpp | .hpp | 1,316 | 47 | /// @ref gtx_texture
/// @file glm/gtx/texture.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_texture GLM_GTX_texture
/// @ingroup gtx
///
/// Include <glm/gtx/texture.hpp> to use the features of this extension.
///
/// Wrapping mode of texture coordinates.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/integer.hpp"
#include "../gtx/component_wise.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_texture is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_texture extension included")
#endif
namespace glm
{
/// @addtogroup gtx_texture
/// @{
/// Compute the number of mipmaps levels necessary to create a mipmap complete texture
///
/// @param Extent Extent of the texture base level mipmap
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
/// @tparam T Floating-point or signed integer scalar types
/// @tparam Q Value from qualifier enum
template <length_t L, typename T, qualifier Q>
T levels(vec<L, T, Q> const& Extent);
/// @}
}// namespace glm
#include "texture.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/integer.hpp | .hpp | 2,222 | 77 | /// @ref gtx_integer
/// @file glm/gtx/integer.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_integer GLM_GTX_integer
/// @ingroup gtx
///
/// Include <glm/gtx/integer.hpp> to use the features of this extension.
///
/// Add support for integer for core functions
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/integer.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_integer is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_integer extension included")
#endif
namespace glm
{
/// @addtogroup gtx_integer
/// @{
//! Returns x raised to the y power.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL int pow(int x, uint y);
//! Returns the positive square root of x.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL int sqrt(int x);
//! Returns the floor log2 of x.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL unsigned int floor_log2(unsigned int x);
//! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL int mod(int x, int y);
//! Return the factorial value of a number (!12 max, integer only)
//! From GLM_GTX_integer extension.
template<typename genType>
GLM_FUNC_DECL genType factorial(genType const& x);
//! 32bit signed integer.
//! From GLM_GTX_integer extension.
typedef signed int sint;
//! Returns x raised to the y power.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL uint pow(uint x, uint y);
//! Returns the positive square root of x.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL uint sqrt(uint x);
//! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL uint mod(uint x, uint y);
//! Returns the number of leading zeros.
//! From GLM_GTX_integer extension.
GLM_FUNC_DECL uint nlz(uint x);
/// @}
}//namespace glm
#include "integer.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/type_trait.hpp | .hpp | 2,201 | 86 | /// @ref gtx_type_trait
/// @file glm/gtx/type_trait.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_type_trait GLM_GTX_type_trait
/// @ingroup gtx
///
/// Include <glm/gtx/type_trait.hpp> to use the features of this extension.
///
/// Defines traits for each type.
#pragma once
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_type_trait is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
// Dependency:
#include "../detail/qualifier.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_type_trait extension included")
#endif
namespace glm
{
/// @addtogroup gtx_type_trait
/// @{
template<typename T>
struct type
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = false;
static length_t const components = 0;
static length_t const cols = 0;
static length_t const rows = 0;
};
template<length_t L, typename T, qualifier Q>
struct type<vec<L, T, Q> >
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
static length_t const components = L;
};
template<length_t C, length_t R, typename T, qualifier Q>
struct type<mat<C, R, T, Q> >
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
static length_t const components = C;
static length_t const cols = C;
static length_t const rows = R;
};
template<typename T, qualifier Q>
struct type<qua<T, Q> >
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = true;
static length_t const components = 4;
};
template<typename T, qualifier Q>
struct type<tdualquat<T, Q> >
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = true;
static length_t const components = 8;
};
/// @}
}//namespace glm
#include "type_trait.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/orthonormalize.hpp | .hpp | 1,351 | 50 | /// @ref gtx_orthonormalize
/// @file glm/gtx/orthonormalize.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_orthonormalize GLM_GTX_orthonormalize
/// @ingroup gtx
///
/// Include <glm/gtx/orthonormalize.hpp> to use the features of this extension.
///
/// Orthonormalize matrices.
#pragma once
// Dependency:
#include "../vec3.hpp"
#include "../mat3x3.hpp"
#include "../geometric.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_orthonormalize is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_orthonormalize extension included")
#endif
namespace glm
{
/// @addtogroup gtx_orthonormalize
/// @{
/// Returns the orthonormalized matrix of m.
///
/// @see gtx_orthonormalize
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<3, 3, T, Q> orthonormalize(mat<3, 3, T, Q> const& m);
/// Orthonormalizes x according y.
///
/// @see gtx_orthonormalize
template<typename T, qualifier Q>
GLM_FUNC_DECL vec<3, T, Q> orthonormalize(vec<3, T, Q> const& x, vec<3, T, Q> const& y);
/// @}
}//namespace glm
#include "orthonormalize.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/intersect.hpp | .hpp | 3,422 | 93 | /// @ref gtx_intersect
/// @file glm/gtx/intersect.hpp
///
/// @see core (dependence)
/// @see gtx_closest_point (dependence)
///
/// @defgroup gtx_intersect GLM_GTX_intersect
/// @ingroup gtx
///
/// Include <glm/gtx/intersect.hpp> to use the features of this extension.
///
/// Add intersection functions
#pragma once
// Dependency:
#include <cfloat>
#include <limits>
#include "../glm.hpp"
#include "../geometric.hpp"
#include "../gtx/closest_point.hpp"
#include "../gtx/vector_query.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_closest_point is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_closest_point extension included")
#endif
namespace glm
{
/// @addtogroup gtx_intersect
/// @{
//! Compute the intersection of a ray and a plane.
//! Ray direction and plane normal must be unit length.
//! From GLM_GTX_intersect extension.
template<typename genType>
GLM_FUNC_DECL bool intersectRayPlane(
genType const& orig, genType const& dir,
genType const& planeOrig, genType const& planeNormal,
typename genType::value_type & intersectionDistance);
//! Compute the intersection of a ray and a triangle.
/// Based om Tomas Möller implementation http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
//! From GLM_GTX_intersect extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool intersectRayTriangle(
vec<3, T, Q> const& orig, vec<3, T, Q> const& dir,
vec<3, T, Q> const& v0, vec<3, T, Q> const& v1, vec<3, T, Q> const& v2,
vec<2, T, Q>& baryPosition, T& distance);
//! Compute the intersection of a line and a triangle.
//! From GLM_GTX_intersect extension.
template<typename genType>
GLM_FUNC_DECL bool intersectLineTriangle(
genType const& orig, genType const& dir,
genType const& vert0, genType const& vert1, genType const& vert2,
genType & position);
//! Compute the intersection distance of a ray and a sphere.
//! The ray direction vector is unit length.
//! From GLM_GTX_intersect extension.
template<typename genType>
GLM_FUNC_DECL bool intersectRaySphere(
genType const& rayStarting, genType const& rayNormalizedDirection,
genType const& sphereCenter, typename genType::value_type const sphereRadiusSquered,
typename genType::value_type & intersectionDistance);
//! Compute the intersection of a ray and a sphere.
//! From GLM_GTX_intersect extension.
template<typename genType>
GLM_FUNC_DECL bool intersectRaySphere(
genType const& rayStarting, genType const& rayNormalizedDirection,
genType const& sphereCenter, const typename genType::value_type sphereRadius,
genType & intersectionPosition, genType & intersectionNormal);
//! Compute the intersection of a line and a sphere.
//! From GLM_GTX_intersect extension
template<typename genType>
GLM_FUNC_DECL bool intersectLineSphere(
genType const& point0, genType const& point1,
genType const& sphereCenter, typename genType::value_type sphereRadius,
genType & intersectionPosition1, genType & intersectionNormal1,
genType & intersectionPosition2 = genType(), genType & intersectionNormal2 = genType());
/// @}
}//namespace glm
#include "intersect.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/hash.hpp | .hpp | 3,469 | 139 | /// @ref gtx_hash
/// @file glm/gtx/hash.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_hash GLM_GTX_hash
/// @ingroup gtx
///
/// Include <glm/gtx/hash.hpp> to use the features of this extension.
///
/// Add std::hash support for glm types
#pragma once
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_hash is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#include <functional>
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../gtc/vec1.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.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"
#if !GLM_HAS_CXX11_STL
# error "GLM_GTX_hash requires C++11 standard library support"
#endif
namespace std
{
template<typename T, glm::qualifier Q>
struct hash<glm::vec<1, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::vec<1, T, Q> const& v) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::vec<2, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::vec<2, T, Q> const& v) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::vec<3, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::vec<3, T, Q> const& v) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::vec<4, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::vec<4, T, Q> const& v) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::tquat<T,Q>>
{
GLM_FUNC_DECL size_t operator()(glm::tquat<T, Q> const& q) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::tdualquat<T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::tdualquat<T,Q> const& q) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<2, 2, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<2, 2, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<2, 3, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<2, 3, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<2, 4, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<2, 4, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<3, 2, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<3, 2, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<3, 3, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<3, 3, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<3, 4, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<3, 4, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<4, 2, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<4, 2, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<4, 3, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<4, 3, T,Q> const& m) const;
};
template<typename T, glm::qualifier Q>
struct hash<glm::mat<4, 4, T,Q> >
{
GLM_FUNC_DECL size_t operator()(glm::mat<4, 4, T,Q> const& m) const;
};
} // namespace std
#include "hash.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/vector_query.hpp | .hpp | 2,248 | 67 | /// @ref gtx_vector_query
/// @file glm/gtx/vector_query.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_vector_query GLM_GTX_vector_query
/// @ingroup gtx
///
/// Include <glm/gtx/vector_query.hpp> to use the features of this extension.
///
/// Query informations of vector types
#pragma once
// Dependency:
#include "../glm.hpp"
#include <cfloat>
#include <limits>
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_vector_query is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_vector_query extension included")
#endif
namespace glm
{
/// @addtogroup gtx_vector_query
/// @{
//! Check whether two vectors are collinears.
/// @see gtx_vector_query extensions.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL bool areCollinear(vec<L, T, Q> const& v0, vec<L, T, Q> const& v1, T const& epsilon);
//! Check whether two vectors are orthogonals.
/// @see gtx_vector_query extensions.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL bool areOrthogonal(vec<L, T, Q> const& v0, vec<L, T, Q> const& v1, T const& epsilon);
//! Check whether a vector is normalized.
/// @see gtx_vector_query extensions.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL bool isNormalized(vec<L, T, Q> const& v, T const& epsilon);
//! Check whether a vector is null.
/// @see gtx_vector_query extensions.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL bool isNull(vec<L, T, Q> const& v, T const& epsilon);
//! Check whether a each component of a vector is null.
/// @see gtx_vector_query extensions.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, bool, Q> isCompNull(vec<L, T, Q> const& v, T const& epsilon);
//! Check whether two vectors are orthonormal.
/// @see gtx_vector_query extensions.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL bool areOrthonormal(vec<L, T, Q> const& v0, vec<L, T, Q> const& v1, T const& epsilon);
/// @}
}// namespace glm
#include "vector_query.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/easing.hpp | .hpp | 7,072 | 220 | /// @ref gtx_easing
/// @file glm/gtx/easing.hpp
/// @author Robert Chisholm
///
/// @see core (dependence)
///
/// @defgroup gtx_easing GLM_GTX_easing
/// @ingroup gtx
///
/// Include <glm/gtx/easing.hpp> to use the features of this extension.
///
/// Easing functions for animations and transitons
/// All functions take a parameter x in the range [0.0,1.0]
///
/// Based on the AHEasing project of Warren Moore (https://github.com/warrenm/AHEasing)
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/constants.hpp"
#include "../detail/qualifier.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_easing is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_easing extension included")
#endif
namespace glm{
/// @addtogroup gtx_easing
/// @{
/// Modelled after the line y = x
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType linearInterpolation(genType const & a);
/// Modelled after the parabola y = x^2
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quadraticEaseIn(genType const & a);
/// Modelled after the parabola y = -x^2 + 2x
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quadraticEaseOut(genType const & a);
/// Modelled after the piecewise quadratic
/// y = (1/2)((2x)^2) ; [0, 0.5)
/// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quadraticEaseInOut(genType const & a);
/// Modelled after the cubic y = x^3
template <typename genType>
GLM_FUNC_DECL genType cubicEaseIn(genType const & a);
/// Modelled after the cubic y = (x - 1)^3 + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType cubicEaseOut(genType const & a);
/// Modelled after the piecewise cubic
/// y = (1/2)((2x)^3) ; [0, 0.5)
/// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType cubicEaseInOut(genType const & a);
/// Modelled after the quartic x^4
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quarticEaseIn(genType const & a);
/// Modelled after the quartic y = 1 - (x - 1)^4
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quarticEaseOut(genType const & a);
/// Modelled after the piecewise quartic
/// y = (1/2)((2x)^4) ; [0, 0.5)
/// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quarticEaseInOut(genType const & a);
/// Modelled after the quintic y = x^5
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quinticEaseIn(genType const & a);
/// Modelled after the quintic y = (x - 1)^5 + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quinticEaseOut(genType const & a);
/// Modelled after the piecewise quintic
/// y = (1/2)((2x)^5) ; [0, 0.5)
/// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quinticEaseInOut(genType const & a);
/// Modelled after quarter-cycle of sine wave
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType sineEaseIn(genType const & a);
/// Modelled after quarter-cycle of sine wave (different phase)
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType sineEaseOut(genType const & a);
/// Modelled after half sine wave
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType sineEaseInOut(genType const & a);
/// Modelled after shifted quadrant IV of unit circle
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType circularEaseIn(genType const & a);
/// Modelled after shifted quadrant II of unit circle
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType circularEaseOut(genType const & a);
/// Modelled after the piecewise circular function
/// y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5)
/// y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType circularEaseInOut(genType const & a);
/// Modelled after the exponential function y = 2^(10(x - 1))
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType exponentialEaseIn(genType const & a);
/// Modelled after the exponential function y = -2^(-10x) + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType exponentialEaseOut(genType const & a);
/// Modelled after the piecewise exponential
/// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
/// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType exponentialEaseInOut(genType const & a);
/// Modelled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1))
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType elasticEaseIn(genType const & a);
/// Modelled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType elasticEaseOut(genType const & a);
/// Modelled after the piecewise exponentially-damped sine wave:
/// y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
/// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType elasticEaseInOut(genType const & a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseIn(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseOut(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseInOut(genType const& a);
/// @param a parameter
/// @param o Optional overshoot modifier
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseIn(genType const& a, genType const& o);
/// @param a parameter
/// @param o Optional overshoot modifier
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseOut(genType const& a, genType const& o);
/// @param a parameter
/// @param o Optional overshoot modifier
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseInOut(genType const& a, genType const& o);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType bounceEaseIn(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType bounceEaseOut(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType bounceEaseInOut(genType const& a);
/// @}
}//namespace glm
#include "easing.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/perpendicular.hpp | .hpp | 1,128 | 42 | /// @ref gtx_perpendicular
/// @file glm/gtx/perpendicular.hpp
///
/// @see core (dependence)
/// @see gtx_projection (dependence)
///
/// @defgroup gtx_perpendicular GLM_GTX_perpendicular
/// @ingroup gtx
///
/// Include <glm/gtx/perpendicular.hpp> to use the features of this extension.
///
/// Perpendicular of a vector from other one
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/projection.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_perpendicular is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_perpendicular extension included")
#endif
namespace glm
{
/// @addtogroup gtx_perpendicular
/// @{
//! Projects x a perpendicular axis of Normal.
//! From GLM_GTX_perpendicular extension.
template<typename genType>
GLM_FUNC_DECL genType perp(genType const& x, genType const& Normal);
/// @}
}//namespace glm
#include "perpendicular.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_query.hpp | .hpp | 2,801 | 78 | /// @ref gtx_matrix_query
/// @file glm/gtx/matrix_query.hpp
///
/// @see core (dependence)
/// @see gtx_vector_query (dependence)
///
/// @defgroup gtx_matrix_query GLM_GTX_matrix_query
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_query.hpp> to use the features of this extension.
///
/// Query to evaluate matrix properties
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/vector_query.hpp"
#include <limits>
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_query is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_matrix_query extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_query
/// @{
/// Return whether a matrix a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool isNull(mat<2, 2, T, Q> const& m, T const& epsilon);
/// Return whether a matrix a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool isNull(mat<3, 3, T, Q> const& m, T const& epsilon);
/// Return whether a matrix is a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool isNull(mat<4, 4, T, Q> const& m, T const& epsilon);
/// Return whether a matrix is an identity matrix.
/// From GLM_GTX_matrix_query extension.
template<length_t C, length_t R, typename T, qualifier Q, template<length_t, length_t, typename, qualifier> class matType>
GLM_FUNC_DECL bool isIdentity(matType<C, R, T, Q> const& m, T const& epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool isNormalized(mat<2, 2, T, Q> const& m, T const& epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool isNormalized(mat<3, 3, T, Q> const& m, T const& epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL bool isNormalized(mat<4, 4, T, Q> const& m, T const& epsilon);
/// Return whether a matrix is an orthonormalized matrix.
/// From GLM_GTX_matrix_query extension.
template<length_t C, length_t R, typename T, qualifier Q, template<length_t, length_t, typename, qualifier> class matType>
GLM_FUNC_DECL bool isOrthogonal(matType<C, R, T, Q> const& m, T const& epsilon);
/// @}
}//namespace glm
#include "matrix_query.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/extend.hpp | .hpp | 1,091 | 43 | /// @ref gtx_extend
/// @file glm/gtx/extend.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_extend GLM_GTX_extend
/// @ingroup gtx
///
/// Include <glm/gtx/extend.hpp> to use the features of this extension.
///
/// Extend a position from a source to a position at a defined length.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_extend is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_extend extension included")
#endif
namespace glm
{
/// @addtogroup gtx_extend
/// @{
/// Extends of Length the Origin position using the (Source - Origin) direction.
/// @see gtx_extend
template<typename genType>
GLM_FUNC_DECL genType extend(
genType const& Origin,
genType const& Source,
typename genType::value_type const Length);
/// @}
}//namespace glm
#include "extend.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/bit.hpp | .hpp | 3,175 | 99 | /// @ref gtx_bit
/// @file glm/gtx/bit.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_bit GLM_GTX_bit
/// @ingroup gtx
///
/// Include <glm/gtx/bit.hpp> to use the features of this extension.
///
/// Allow to perform bit operations on integer values
#pragma once
// Dependencies
#include "../gtc/bitfield.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_bit is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_bit extension is deprecated, include GLM_GTC_bitfield and GLM_GTC_integer instead")
#endif
namespace glm
{
/// @addtogroup gtx_bit
/// @{
/// @see gtx_bit
template<typename genIUType>
GLM_FUNC_DECL genIUType highestBitValue(genIUType Value);
/// @see gtx_bit
template<typename genIUType>
GLM_FUNC_DECL genIUType lowestBitValue(genIUType Value);
/// Find the highest bit set to 1 in a integer variable and return its value.
///
/// @see gtx_bit
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> highestBitValue(vec<L, T, Q> const& value);
/// Return the power of two number which value is just higher the input value.
/// Deprecated, use ceilPowerOfTwo from GTC_round instead
///
/// @see gtc_round
/// @see gtx_bit
template<typename genIUType>
GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoAbove(genIUType Value);
/// Return the power of two number which value is just higher the input value.
/// Deprecated, use ceilPowerOfTwo from GTC_round instead
///
/// @see gtc_round
/// @see gtx_bit
template<length_t L, typename T, qualifier Q>
GLM_DEPRECATED GLM_FUNC_DECL vec<L, T, Q> powerOfTwoAbove(vec<L, T, Q> const& value);
/// Return the power of two number which value is just lower the input value.
/// Deprecated, use floorPowerOfTwo from GTC_round instead
///
/// @see gtc_round
/// @see gtx_bit
template<typename genIUType>
GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoBelow(genIUType Value);
/// Return the power of two number which value is just lower the input value.
/// Deprecated, use floorPowerOfTwo from GTC_round instead
///
/// @see gtc_round
/// @see gtx_bit
template<length_t L, typename T, qualifier Q>
GLM_DEPRECATED GLM_FUNC_DECL vec<L, T, Q> powerOfTwoBelow(vec<L, T, Q> const& value);
/// Return the power of two number which value is the closet to the input value.
/// Deprecated, use roundPowerOfTwo from GTC_round instead
///
/// @see gtc_round
/// @see gtx_bit
template<typename genIUType>
GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoNearest(genIUType Value);
/// Return the power of two number which value is the closet to the input value.
/// Deprecated, use roundPowerOfTwo from GTC_round instead
///
/// @see gtc_round
/// @see gtx_bit
template<length_t L, typename T, qualifier Q>
GLM_DEPRECATED GLM_FUNC_DECL vec<L, T, Q> powerOfTwoNearest(vec<L, T, Q> const& value);
/// @}
} //namespace glm
#include "bit.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/projection.hpp | .hpp | 997 | 41 | /// @ref gtx_projection
/// @file glm/gtx/projection.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_projection GLM_GTX_projection
/// @ingroup gtx
///
/// Include <glm/gtx/projection.hpp> to use the features of this extension.
///
/// Projection of a vector to other one
#pragma once
// Dependency:
#include "../geometric.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_projection is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_projection extension included")
#endif
namespace glm
{
/// @addtogroup gtx_projection
/// @{
/// Projects x on Normal.
///
/// @see gtx_projection
template<typename genType>
GLM_FUNC_DECL genType proj(genType const& x, genType const& Normal);
/// @}
}//namespace glm
#include "projection.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/string_cast.hpp | .hpp | 1,415 | 53 | /// @ref gtx_string_cast
/// @file glm/gtx/string_cast.hpp
///
/// @see core (dependence)
/// @see gtx_integer (dependence)
/// @see gtx_quaternion (dependence)
///
/// @defgroup gtx_string_cast GLM_GTX_string_cast
/// @ingroup gtx
///
/// Include <glm/gtx/string_cast.hpp> to use the features of this extension.
///
/// Setup strings for GLM type values
///
/// This extension is not supported with CUDA
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/type_precision.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.hpp"
#include <string>
#include <cmath>
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_string_cast is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if(GLM_COMPILER & GLM_COMPILER_CUDA)
# error "GLM_GTX_string_cast is not supported on CUDA compiler"
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_string_cast extension included")
#endif
namespace glm
{
/// @addtogroup gtx_string_cast
/// @{
/// Create a string from a GLM vector or matrix typed variable.
/// @see gtx_string_cast extension.
template<typename genType>
GLM_FUNC_DECL std::string to_string(genType const& x);
/// @}
}//namespace glm
#include "string_cast.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/number_precision.hpp | .hpp | 2,363 | 62 | /// @ref gtx_number_precision
/// @file glm/gtx/number_precision.hpp
///
/// @see core (dependence)
/// @see gtc_type_precision (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtx_number_precision GLM_GTX_number_precision
/// @ingroup gtx
///
/// Include <glm/gtx/number_precision.hpp> to use the features of this extension.
///
/// Defined size types.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/type_precision.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_number_precision is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_number_precision extension included")
#endif
namespace glm{
namespace gtx
{
/////////////////////////////
// Unsigned int vector types
/// @addtogroup gtx_number_precision
/// @{
typedef u8 u8vec1; //!< \brief 8bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
typedef u16 u16vec1; //!< \brief 16bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
typedef u32 u32vec1; //!< \brief 32bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
typedef u64 u64vec1; //!< \brief 64bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
//////////////////////
// Float vector types
typedef f32 f32vec1; //!< \brief Single-qualifier floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f64 f64vec1; //!< \brief Single-qualifier floating-point scalar. (from GLM_GTX_number_precision extension)
//////////////////////
// Float matrix types
typedef f32 f32mat1; //!< \brief Single-qualifier floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f32 f32mat1x1; //!< \brief Single-qualifier floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f64 f64mat1; //!< \brief Double-qualifier floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f64 f64mat1x1; //!< \brief Double-qualifier floating-point scalar. (from GLM_GTX_number_precision extension)
/// @}
}//namespace gtx
}//namespace glm
#include "number_precision.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/std_based_type.hpp | .hpp | 2,061 | 69 | /// @ref gtx_std_based_type
/// @file glm/gtx/std_based_type.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_std_based_type GLM_GTX_std_based_type
/// @ingroup gtx
///
/// Include <glm/gtx/std_based_type.hpp> to use the features of this extension.
///
/// Adds vector types based on STL value types.
#pragma once
// Dependency:
#include "../glm.hpp"
#include <cstdlib>
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_std_based_type is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_std_based_type extension included")
#endif
namespace glm
{
/// @addtogroup gtx_std_based_type
/// @{
/// Vector type based of one std::size_t component.
/// @see GLM_GTX_std_based_type
typedef vec<1, std::size_t, defaultp> size1;
/// Vector type based of two std::size_t components.
/// @see GLM_GTX_std_based_type
typedef vec<2, std::size_t, defaultp> size2;
/// Vector type based of three std::size_t components.
/// @see GLM_GTX_std_based_type
typedef vec<3, std::size_t, defaultp> size3;
/// Vector type based of four std::size_t components.
/// @see GLM_GTX_std_based_type
typedef vec<4, std::size_t, defaultp> size4;
/// Vector type based of one std::size_t component.
/// @see GLM_GTX_std_based_type
typedef vec<1, std::size_t, defaultp> size1_t;
/// Vector type based of two std::size_t components.
/// @see GLM_GTX_std_based_type
typedef vec<2, std::size_t, defaultp> size2_t;
/// Vector type based of three std::size_t components.
/// @see GLM_GTX_std_based_type
typedef vec<3, std::size_t, defaultp> size3_t;
/// Vector type based of four std::size_t components.
/// @see GLM_GTX_std_based_type
typedef vec<4, std::size_t, defaultp> size4_t;
/// @}
}//namespace glm
#include "std_based_type.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/component_wise.hpp | .hpp | 2,400 | 70 | /// @ref gtx_component_wise
/// @file glm/gtx/component_wise.hpp
/// @date 2007-05-21 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtx_component_wise GLM_GTX_component_wise
/// @ingroup gtx
///
/// Include <glm/gtx/component_wise.hpp> to use the features of this extension.
///
/// Operations between components of a type
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_component_wise is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_component_wise extension included")
#endif
namespace glm
{
/// @addtogroup gtx_component_wise
/// @{
/// Convert an integer vector to a normalized float vector.
/// If the parameter value type is already a floating qualifier type, the value is passed through.
/// @see gtx_component_wise
template<typename floatType, length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, floatType, Q> compNormalize(vec<L, T, Q> const& v);
/// Convert a normalized float vector to an integer vector.
/// If the parameter value type is already a floating qualifier type, the value is passed through.
/// @see gtx_component_wise
template<length_t L, typename T, typename floatType, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> compScale(vec<L, floatType, Q> const& v);
/// Add all vector components together.
/// @see gtx_component_wise
template<typename genType>
GLM_FUNC_DECL typename genType::value_type compAdd(genType const& v);
/// Multiply all vector components together.
/// @see gtx_component_wise
template<typename genType>
GLM_FUNC_DECL typename genType::value_type compMul(genType const& v);
/// Find the minimum value between single vector components.
/// @see gtx_component_wise
template<typename genType>
GLM_FUNC_DECL typename genType::value_type compMin(genType const& v);
/// Find the maximum value between single vector components.
/// @see gtx_component_wise
template<typename genType>
GLM_FUNC_DECL typename genType::value_type compMax(genType const& v);
/// @}
}//namespace glm
#include "component_wise.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/norm.hpp | .hpp | 2,333 | 77 | /// @ref gtx_norm
/// @file glm/gtx/norm.hpp
///
/// @see core (dependence)
/// @see gtx_quaternion (dependence)
///
/// @defgroup gtx_norm GLM_GTX_norm
/// @ingroup gtx
///
/// Include <glm/gtx/norm.hpp> to use the features of this extension.
///
/// Various ways to compute vector norms.
#pragma once
// Dependency:
#include "../geometric.hpp"
#include "../gtx/quaternion.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_norm is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_norm extension included")
#endif
namespace glm
{
/// @addtogroup gtx_norm
/// @{
/// Returns the squared length of x.
/// From GLM_GTX_norm extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T length2(vec<L, T, Q> const& x);
/// Returns the squared distance between p0 and p1, i.e., length2(p0 - p1).
/// From GLM_GTX_norm extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T distance2(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1);
//! Returns the L1 norm between x and y.
//! From GLM_GTX_norm extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T l1Norm(vec<3, T, Q> const& x, vec<3, T, Q> const& y);
//! Returns the L1 norm of v.
//! From GLM_GTX_norm extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T l1Norm(vec<3, T, Q> const& v);
//! Returns the L2 norm between x and y.
//! From GLM_GTX_norm extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T l2Norm(vec<3, T, Q> const& x, vec<3, T, Q> const& y);
//! Returns the L2 norm of v.
//! From GLM_GTX_norm extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T l2Norm(vec<3, T, Q> const& x);
//! Returns the L norm between x and y.
//! From GLM_GTX_norm extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T lxNorm(vec<3, T, Q> const& x, vec<3, T, Q> const& y, unsigned int Depth);
//! Returns the L norm of v.
//! From GLM_GTX_norm extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T lxNorm(vec<3, T, Q> const& x, unsigned int Depth);
/// @}
}//namespace glm
#include "norm.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_interpolation.hpp | .hpp | 2,038 | 61 | /// @ref gtx_matrix_interpolation
/// @file glm/gtx/matrix_interpolation.hpp
/// @author Ghenadii Ursachi (the.asteroth@gmail.com)
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_interpolation GLM_GTX_matrix_interpolation
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_interpolation.hpp> to use the features of this extension.
///
/// Allows to directly interpolate two matrices.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_interpolation is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_matrix_interpolation extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_interpolation
/// @{
/// Get the axis and angle of the rotation from a matrix.
/// From GLM_GTX_matrix_interpolation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL void axisAngle(
mat<4, 4, T, Q> const& Mat, vec<3, T, Q> & Axis, T & Angle);
/// Build a matrix from axis and angle.
/// From GLM_GTX_matrix_interpolation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> axisAngleMatrix(
vec<3, T, Q> const& Axis, T const Angle);
/// Extracts the rotation part of a matrix.
/// From GLM_GTX_matrix_interpolation extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> extractMatrixRotation(
mat<4, 4, T, Q> const& Mat);
/// Build a interpolation of 4 * 4 matrixes.
/// From GLM_GTX_matrix_interpolation extension.
/// Warning! works only with rotation and/or translation matrixes, scale will generate unexpected results.
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> interpolate(
mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2, T const Delta);
/// @}
}//namespace glm
#include "matrix_interpolation.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/compatibility.hpp | .hpp | 15,102 | 134 | /// @ref gtx_compatibility
/// @file glm/gtx/compatibility.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_compatibility GLM_GTX_compatibility
/// @ingroup gtx
///
/// Include <glm/gtx/compatibility.hpp> to use the features of this extension.
///
/// Provide functions to increase the compatibility with Cg and HLSL languages
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/quaternion.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_compatibility is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_compatibility extension included")
#endif
#if GLM_COMPILER & GLM_COMPILER_VC
# include <cfloat>
#elif GLM_COMPILER & GLM_COMPILER_GCC
# include <cmath>
# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
# undef isfinite
# endif
#endif//GLM_COMPILER
namespace glm
{
/// @addtogroup gtx_compatibility
/// @{
template<typename T> GLM_FUNC_QUALIFIER T lerp(T x, T y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<2, T, Q> lerp(const vec<2, T, Q>& x, const vec<2, T, Q>& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<3, T, Q> lerp(const vec<3, T, Q>& x, const vec<3, T, Q>& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<4, T, Q> lerp(const vec<4, T, Q>& x, const vec<4, T, Q>& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<2, T, Q> lerp(const vec<2, T, Q>& x, const vec<2, T, Q>& y, const vec<2, T, Q>& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<3, T, Q> lerp(const vec<3, T, Q>& x, const vec<3, T, Q>& y, const vec<3, T, Q>& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<4, T, Q> lerp(const vec<4, T, Q>& x, const vec<4, T, Q>& y, const vec<4, T, Q>& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER T saturate(T x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<2, T, Q> saturate(const vec<2, T, Q>& x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<3, T, Q> saturate(const vec<3, T, Q>& x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<4, T, Q> saturate(const vec<4, T, Q>& x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER T atan2(T x, T y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<2, T, Q> atan2(const vec<2, T, Q>& x, const vec<2, T, Q>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<3, T, Q> atan2(const vec<3, T, Q>& x, const vec<3, T, Q>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_QUALIFIER vec<4, T, Q> atan2(const vec<4, T, Q>& x, const vec<4, T, Q>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility)
template<typename genType> GLM_FUNC_DECL bool isfinite(genType const& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<1, bool, Q> isfinite(const vec<1, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<2, bool, Q> isfinite(const vec<2, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<3, bool, Q> isfinite(const vec<3, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<4, bool, Q> isfinite(const vec<4, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
typedef bool bool1; //!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension)
typedef vec<2, bool, highp> bool2; //!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension)
typedef vec<3, bool, highp> bool3; //!< \brief boolean type with 3 components. (From GLM_GTX_compatibility extension)
typedef vec<4, bool, highp> bool4; //!< \brief boolean type with 4 components. (From GLM_GTX_compatibility extension)
typedef bool bool1x1; //!< \brief boolean matrix with 1 x 1 component. (From GLM_GTX_compatibility extension)
typedef mat<2, 2, bool, highp> bool2x2; //!< \brief boolean matrix with 2 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 3, bool, highp> bool2x3; //!< \brief boolean matrix with 2 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 4, bool, highp> bool2x4; //!< \brief boolean matrix with 2 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 2, bool, highp> bool3x2; //!< \brief boolean matrix with 3 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 3, bool, highp> bool3x3; //!< \brief boolean matrix with 3 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 4, bool, highp> bool3x4; //!< \brief boolean matrix with 3 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 2, bool, highp> bool4x2; //!< \brief boolean matrix with 4 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 3, bool, highp> bool4x3; //!< \brief boolean matrix with 4 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 4, bool, highp> bool4x4; //!< \brief boolean matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
typedef int int1; //!< \brief integer vector with 1 component. (From GLM_GTX_compatibility extension)
typedef vec<2, int, highp> int2; //!< \brief integer vector with 2 components. (From GLM_GTX_compatibility extension)
typedef vec<3, int, highp> int3; //!< \brief integer vector with 3 components. (From GLM_GTX_compatibility extension)
typedef vec<4, int, highp> int4; //!< \brief integer vector with 4 components. (From GLM_GTX_compatibility extension)
typedef int int1x1; //!< \brief integer matrix with 1 component. (From GLM_GTX_compatibility extension)
typedef mat<2, 2, int, highp> int2x2; //!< \brief integer matrix with 2 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 3, int, highp> int2x3; //!< \brief integer matrix with 2 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 4, int, highp> int2x4; //!< \brief integer matrix with 2 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 2, int, highp> int3x2; //!< \brief integer matrix with 3 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 3, int, highp> int3x3; //!< \brief integer matrix with 3 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 4, int, highp> int3x4; //!< \brief integer matrix with 3 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 2, int, highp> int4x2; //!< \brief integer matrix with 4 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 3, int, highp> int4x3; //!< \brief integer matrix with 4 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 4, int, highp> int4x4; //!< \brief integer matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
typedef float float1; //!< \brief single-qualifier floating-point vector with 1 component. (From GLM_GTX_compatibility extension)
typedef vec<2, float, highp> float2; //!< \brief single-qualifier floating-point vector with 2 components. (From GLM_GTX_compatibility extension)
typedef vec<3, float, highp> float3; //!< \brief single-qualifier floating-point vector with 3 components. (From GLM_GTX_compatibility extension)
typedef vec<4, float, highp> float4; //!< \brief single-qualifier floating-point vector with 4 components. (From GLM_GTX_compatibility extension)
typedef float float1x1; //!< \brief single-qualifier floating-point matrix with 1 component. (From GLM_GTX_compatibility extension)
typedef mat<2, 2, float, highp> float2x2; //!< \brief single-qualifier floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 3, float, highp> float2x3; //!< \brief single-qualifier floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 4, float, highp> float2x4; //!< \brief single-qualifier floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 2, float, highp> float3x2; //!< \brief single-qualifier floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 3, float, highp> float3x3; //!< \brief single-qualifier floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 4, float, highp> float3x4; //!< \brief single-qualifier floating-point matrix with 3 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 2, float, highp> float4x2; //!< \brief single-qualifier floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 3, float, highp> float4x3; //!< \brief single-qualifier floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 4, float, highp> float4x4; //!< \brief single-qualifier floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
typedef double double1; //!< \brief double-qualifier floating-point vector with 1 component. (From GLM_GTX_compatibility extension)
typedef vec<2, double, highp> double2; //!< \brief double-qualifier floating-point vector with 2 components. (From GLM_GTX_compatibility extension)
typedef vec<3, double, highp> double3; //!< \brief double-qualifier floating-point vector with 3 components. (From GLM_GTX_compatibility extension)
typedef vec<4, double, highp> double4; //!< \brief double-qualifier floating-point vector with 4 components. (From GLM_GTX_compatibility extension)
typedef double double1x1; //!< \brief double-qualifier floating-point matrix with 1 component. (From GLM_GTX_compatibility extension)
typedef mat<2, 2, double, highp> double2x2; //!< \brief double-qualifier floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 3, double, highp> double2x3; //!< \brief double-qualifier floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<2, 4, double, highp> double2x4; //!< \brief double-qualifier floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 2, double, highp> double3x2; //!< \brief double-qualifier floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 3, double, highp> double3x3; //!< \brief double-qualifier floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<3, 4, double, highp> double3x4; //!< \brief double-qualifier floating-point matrix with 3 x 4 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 2, double, highp> double4x2; //!< \brief double-qualifier floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 3, double, highp> double4x3; //!< \brief double-qualifier floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension)
typedef mat<4, 4, double, highp> double4x4; //!< \brief double-qualifier floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
/// @}
}//namespace glm
#include "compatibility.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/log_base.hpp | .hpp | 1,198 | 49 | /// @ref gtx_log_base
/// @file glm/gtx/log_base.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_log_base GLM_GTX_log_base
/// @ingroup gtx
///
/// Include <glm/gtx/log_base.hpp> to use the features of this extension.
///
/// Logarithm for any base. base can be a vector or a scalar.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_log_base is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_log_base extension included")
#endif
namespace glm
{
/// @addtogroup gtx_log_base
/// @{
/// Logarithm for any base.
/// From GLM_GTX_log_base.
template<typename genType>
GLM_FUNC_DECL genType log(
genType const& x,
genType const& base);
/// Logarithm for any base.
/// From GLM_GTX_log_base.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> sign(
vec<L, T, Q> const& x,
vec<L, T, Q> const& base);
/// @}
}//namespace glm
#include "log_base.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_decompose.hpp | .hpp | 1,423 | 47 | /// @ref gtx_matrix_decompose
/// @file glm/gtx/matrix_decompose.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_decompose GLM_GTX_matrix_decompose
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_decompose.hpp> to use the features of this extension.
///
/// Decomposes a model matrix to translations, rotation and scale components
#pragma once
// Dependencies
#include "../mat4x4.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../geometric.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtc/matrix_transform.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_decompose is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_matrix_decompose extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_decompose
/// @{
/// Decomposes a model matrix to translations, rotation and scale components
/// @see gtx_matrix_decompose
template<typename T, qualifier Q>
GLM_FUNC_DECL bool decompose(
mat<4, 4, T, Q> const& modelMatrix,
vec<3, T, Q> & scale, qua<T, Q> & orientation, vec<3, T, Q> & translation, vec<3, T, Q> & skew, vec<4, T, Q> & perspective);
/// @}
}//namespace glm
#include "matrix_decompose.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/matrix_factorisation.hpp | .hpp | 2,936 | 70 | /// @ref gtx_matrix_factorisation
/// @file glm/gtx/matrix_factorisation.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_factorisation GLM_GTX_matrix_factorisation
/// @ingroup gtx
///
/// Include <glm/gtx/matrix_factorisation.hpp> to use the features of this extension.
///
/// Functions to factor matrices in various forms
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_matrix_factorisation is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_matrix_factorisation extension included")
#endif
/*
Suggestions:
- Move helper functions flipud and fliplr to another file: They may be helpful in more general circumstances.
- Implement other types of matrix factorisation, such as: QL and LQ, L(D)U, eigendecompositions, etc...
*/
namespace glm
{
/// @addtogroup gtx_matrix_factorisation
/// @{
/// Flips the matrix rows up and down.
///
/// From GLM_GTX_matrix_factorisation extension.
template <length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL mat<C, R, T, Q> flipud(mat<C, R, T, Q> const& in);
/// Flips the matrix columns right and left.
///
/// From GLM_GTX_matrix_factorisation extension.
template <length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL mat<C, R, T, Q> fliplr(mat<C, R, T, Q> const& in);
/// Performs QR factorisation of a matrix.
/// Returns 2 matrices, q and r, such that the columns of q are orthonormal and span the same subspace than those of the input matrix, r is an upper triangular matrix, and q*r=in.
/// Given an n-by-m input matrix, q has dimensions min(n,m)-by-m, and r has dimensions n-by-min(n,m).
///
/// From GLM_GTX_matrix_factorisation extension.
template <length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL void qr_decompose(mat<C, R, T, Q> const& in, mat<(C < R ? C : R), R, T, Q>& q, mat<C, (C < R ? C : R), T, Q>& r);
/// Performs RQ factorisation of a matrix.
/// Returns 2 matrices, r and q, such that r is an upper triangular matrix, the rows of q are orthonormal and span the same subspace than those of the input matrix, and r*q=in.
/// Note that in the context of RQ factorisation, the diagonal is seen as starting in the lower-right corner of the matrix, instead of the usual upper-left.
/// Given an n-by-m input matrix, r has dimensions min(n,m)-by-m, and q has dimensions n-by-min(n,m).
///
/// From GLM_GTX_matrix_factorisation extension.
template <length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL void rq_decompose(mat<C, R, T, Q> const& in, mat<(C < R ? C : R), R, T, Q>& r, mat<C, (C < R ? C : R), T, Q>& q);
/// @}
}
#include "matrix_factorisation.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/wrap.hpp | .hpp | 1,475 | 56 | /// @ref gtx_wrap
/// @file glm/gtx/wrap.hpp
///
/// @see core (dependence)
///
/// @defgroup gtx_wrap GLM_GTX_wrap
/// @ingroup gtx
///
/// Include <glm/gtx/wrap.hpp> to use the features of this extension.
///
/// Wrapping mode of texture coordinates.
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/vec1.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_wrap is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_wrap extension included")
#endif
namespace glm
{
/// @addtogroup gtx_wrap
/// @{
/// Simulate GL_CLAMP OpenGL wrap mode
/// @see gtx_wrap extension.
template<typename genType>
GLM_FUNC_DECL genType clamp(genType const& Texcoord);
/// Simulate GL_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template<typename genType>
GLM_FUNC_DECL genType repeat(genType const& Texcoord);
/// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template<typename genType>
GLM_FUNC_DECL genType mirrorClamp(genType const& Texcoord);
/// Simulate GL_MIRROR_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template<typename genType>
GLM_FUNC_DECL genType mirrorRepeat(genType const& Texcoord);
/// @}
}// namespace glm
#include "wrap.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/associated_min_max.hpp | .hpp | 7,812 | 208 | /// @ref gtx_associated_min_max
/// @file glm/gtx/associated_min_max.hpp
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_associated_min_max GLM_GTX_associated_min_max
/// @ingroup gtx
///
/// Include <glm/gtx/associated_min_max.hpp> to use the features of this extension.
///
/// @brief Min and max functions that return associated values not the compared onces.
#pragma once
// Dependency:
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GTX_associated_min_max is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_associated_min_max extension included")
#endif
namespace glm
{
/// @addtogroup gtx_associated_min_max
/// @{
/// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, qualifier Q>
GLM_FUNC_DECL U associatedMin(T x, U a, T y, U b);
/// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<2, U, Q> associatedMin(
vec<L, T, Q> const& x, vec<L, U, Q> const& a,
vec<L, T, Q> const& y, vec<L, U, Q> const& b);
/// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMin(
T x, const vec<L, U, Q>& a,
T y, const vec<L, U, Q>& b);
/// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMin(
vec<L, T, Q> const& x, U a,
vec<L, T, Q> const& y, U b);
/// Minimum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
GLM_FUNC_DECL U associatedMin(
T x, U a,
T y, U b,
T z, U c);
/// Minimum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMin(
vec<L, T, Q> const& x, vec<L, U, Q> const& a,
vec<L, T, Q> const& y, vec<L, U, Q> const& b,
vec<L, T, Q> const& z, vec<L, U, Q> const& c);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
GLM_FUNC_DECL U associatedMin(
T x, U a,
T y, U b,
T z, U c,
T w, U d);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMin(
vec<L, T, Q> const& x, vec<L, U, Q> const& a,
vec<L, T, Q> const& y, vec<L, U, Q> const& b,
vec<L, T, Q> const& z, vec<L, U, Q> const& c,
vec<L, T, Q> const& w, vec<L, U, Q> const& d);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMin(
T x, vec<L, U, Q> const& a,
T y, vec<L, U, Q> const& b,
T z, vec<L, U, Q> const& c,
T w, vec<L, U, Q> const& d);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMin(
vec<L, T, Q> const& x, U a,
vec<L, T, Q> const& y, U b,
vec<L, T, Q> const& z, U c,
vec<L, T, Q> const& w, U d);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
GLM_FUNC_DECL U associatedMax(T x, U a, T y, U b);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<2, U, Q> associatedMax(
vec<L, T, Q> const& x, vec<L, U, Q> const& a,
vec<L, T, Q> const& y, vec<L, U, Q> const& b);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> associatedMax(
T x, vec<L, U, Q> const& a,
T y, vec<L, U, Q> const& b);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMax(
vec<L, T, Q> const& x, U a,
vec<L, T, Q> const& y, U b);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
GLM_FUNC_DECL U associatedMax(
T x, U a,
T y, U b,
T z, U c);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMax(
vec<L, T, Q> const& x, vec<L, U, Q> const& a,
vec<L, T, Q> const& y, vec<L, U, Q> const& b,
vec<L, T, Q> const& z, vec<L, U, Q> const& c);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> associatedMax(
T x, vec<L, U, Q> const& a,
T y, vec<L, U, Q> const& b,
T z, vec<L, U, Q> const& c);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMax(
vec<L, T, Q> const& x, U a,
vec<L, T, Q> const& y, U b,
vec<L, T, Q> const& z, U c);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
GLM_FUNC_DECL U associatedMax(
T x, U a,
T y, U b,
T z, U c,
T w, U d);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMax(
vec<L, T, Q> const& x, vec<L, U, Q> const& a,
vec<L, T, Q> const& y, vec<L, U, Q> const& b,
vec<L, T, Q> const& z, vec<L, U, Q> const& c,
vec<L, T, Q> const& w, vec<L, U, Q> const& d);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMax(
T x, vec<L, U, Q> const& a,
T y, vec<L, U, Q> const& b,
T z, vec<L, U, Q> const& c,
T w, vec<L, U, Q> const& d);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<length_t L, typename T, typename U, qualifier Q>
GLM_FUNC_DECL vec<L, U, Q> associatedMax(
vec<L, T, Q> const& x, U a,
vec<L, T, Q> const& y, U b,
vec<L, T, Q> const& z, U c,
vec<L, T, Q> const& w, U d);
/// @}
} //namespace glm
#include "associated_min_max.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/normalize_dot.hpp | .hpp | 1,559 | 50 | /// @ref gtx_normalize_dot
/// @file glm/gtx/normalize_dot.hpp
///
/// @see core (dependence)
/// @see gtx_fast_square_root (dependence)
///
/// @defgroup gtx_normalize_dot GLM_GTX_normalize_dot
/// @ingroup gtx
///
/// Include <glm/gtx/normalized_dot.hpp> to use the features of this extension.
///
/// Dot product of vectors that need to be normalize with a single square root.
#pragma once
// Dependency:
#include "../gtx/fast_square_root.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_normalize_dot is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_normalize_dot extension included")
#endif
namespace glm
{
/// @addtogroup gtx_normalize_dot
/// @{
/// Normalize parameters and returns the dot product of x and y.
/// It's faster that dot(normalize(x), normalize(y)).
///
/// @see gtx_normalize_dot extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T normalizeDot(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Normalize parameters and returns the dot product of x and y.
/// Faster that dot(fastNormalize(x), fastNormalize(y)).
///
/// @see gtx_normalize_dot extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T fastNormalizeDot(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// @}
}//namespace glm
#include "normalize_dot.inl"
| Unknown |
3D | mcellteam/mcell | libs/glm/gtx/vector_angle.hpp | .hpp | 1,830 | 58 | /// @ref gtx_vector_angle
/// @file glm/gtx/vector_angle.hpp
///
/// @see core (dependence)
/// @see gtx_quaternion (dependence)
/// @see gtx_epsilon (dependence)
///
/// @defgroup gtx_vector_angle GLM_GTX_vector_angle
/// @ingroup gtx
///
/// Include <glm/gtx/vector_angle.hpp> to use the features of this extension.
///
/// Compute angle between vectors
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/epsilon.hpp"
#include "../gtx/quaternion.hpp"
#include "../gtx/rotate_vector.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
# error "GLM: GLM_GTX_vector_angle is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
#endif
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTX_vector_angle extension included")
#endif
namespace glm
{
/// @addtogroup gtx_vector_angle
/// @{
//! Returns the absolute angle between two vectors.
//! Parameters need to be normalized.
/// @see gtx_vector_angle extension.
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T angle(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
//! Returns the oriented angle between two 2d vectors.
//! Parameters need to be normalized.
/// @see gtx_vector_angle extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T orientedAngle(vec<2, T, Q> const& x, vec<2, T, Q> const& y);
//! Returns the oriented angle between two 3d vectors based from a reference axis.
//! Parameters need to be normalized.
/// @see gtx_vector_angle extension.
template<typename T, qualifier Q>
GLM_FUNC_DECL T orientedAngle(vec<3, T, Q> const& x, vec<3, T, Q> const& y, vec<3, T, Q> const& ref);
/// @}
}// namespace glm
#include "vector_angle.inl"
| Unknown |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.