Make C++98 compliant

This commit is contained in:
Vincent Aymong
2017-07-06 17:45:40 -04:00
parent edde2bcf60
commit f9962054d9
3 changed files with 17 additions and 18 deletions

View File

@@ -13,7 +13,6 @@
#pragma once
// Dependency:
#include <algorithm>
#include "../glm.hpp"
#ifndef GLM_ENABLE_EXPERIMENTAL
@@ -49,7 +48,7 @@ namespace glm{
/// 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, precision P, template<length_t, length_t, typename, precision> class matType>
GLM_FUNC_DECL void qr_decompose(matType<std::min(C, R), R, T, P>& q, matType<C, std::min(C, R), T, P>& r, const matType<C, R, T, P>& in);
GLM_FUNC_DECL void qr_decompose(matType<(C < R ? C : R), R, T, P>& q, matType<C, (C < R ? C : R), T, P>& r, const matType<C, R, T, P>& in);
/// 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.
@@ -57,7 +56,7 @@ namespace glm{
/// 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, precision P, template<length_t, length_t, typename, precision> class matType>
GLM_FUNC_DECL void rq_decompose(matType<std::min(C, R), R, T, P>& r, matType<C, std::min(C, R), T, P>& q, const matType<C, R, T, P>& in);
GLM_FUNC_DECL void rq_decompose(matType<(C < R ? C : R), R, T, P>& r, matType<C, (C < R ? C : R), T, P>& q, const matType<C, R, T, P>& in);
/// @}
}

View File

@@ -24,14 +24,14 @@ namespace glm {
}
template <length_t C, length_t R, typename T, precision P, template<length_t, length_t, typename, precision> class matType>
GLM_FUNC_QUALIFIER void qr_decompose(matType<std::min(C, R), R, T, P>& q, matType<C, std::min(C, R), T, P>& r, const matType<C, R, T, P>& in) {
GLM_FUNC_QUALIFIER void qr_decompose(matType<(C < R ? C : R), R, T, P>& q, matType<C, (C < R ? C : R), T, P>& r, const matType<C, R, T, P>& in) {
// Uses modified Gram-Schmidt method
// Source: https://en.wikipedia.org/wiki/Gram<61>Schmidt_process
// And https://en.wikipedia.org/wiki/QR_decomposition
//For all the linearly independs columns of the input...
// (there can be no more linearly independents columns than there are rows.)
for (length_t i = 0; i < std::min(R, C); i++) {
for (length_t i = 0; i < (C < R ? C : R); i++) {
//Copy in Q the input's i-th column.
q[i] = in[i];
@@ -55,7 +55,7 @@ namespace glm {
}
template <length_t C, length_t R, typename T, precision P, template<length_t, length_t, typename, precision> class matType>
GLM_FUNC_QUALIFIER void rq_decompose(matType<std::min(C, R), R, T, P>& r, matType<C, std::min(C, R), T, P>& q, const matType<C, R, T, P>& in) {
GLM_FUNC_QUALIFIER void rq_decompose(matType<(C < R ? C : R), R, T, P>& r, matType<C, (C < R ? C : R), T, P>& q, const matType<C, R, T, P>& in) {
// From https://en.wikipedia.org/wiki/QR_decomposition:
// The RQ decomposition transforms a matrix A into the product of an upper triangular matrix R (also known as right-triangular) and an orthogonal matrix Q. The only difference from QR decomposition is the order of these matrices.
// QR decomposition is Gram<61>Schmidt orthogonalization of columns of A, started from the first column.
@@ -64,8 +64,8 @@ namespace glm {
matType<R, C, T, P> tin = transpose(in);
tin = fliplr(tin);
matType<R, std::min(C, R), T, P> tr;
matType<std::min(C, R), C, T, P> tq;
matType<R, (C < R ? C : R), T, P> tr;
matType<(C < R ? C : R), C, T, P> tq;
qr_decompose(tq, tr, tin);
tr = fliplr(tr);