[DEV] replace 'include guard' with 'pragma once'
This commit is contained in:
parent
5844516067
commit
77e7e1bf5e
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_COLOR_H__
|
||||
#define __ETK_COLOR_H__
|
||||
#pragma once
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
@ -747,5 +746,4 @@ namespace etk {
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_HACH_H__
|
||||
#define __ETK_HACH_H__
|
||||
#pragma once
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "etk::Hash"
|
||||
@ -271,5 +270,3 @@ namespace etk {
|
||||
#undef __class__
|
||||
#define __class__ NULL
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_NOISE_H__
|
||||
#define __ETK_NOISE_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/math/Vector2D.h>
|
||||
|
||||
@ -47,6 +46,5 @@ namespace etk {
|
||||
~Noise();
|
||||
float get(int32_t _x, int32_t _y) const;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_ARCHIVE_H__
|
||||
#define __ETK_ARCHIVE_H__
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
@ -146,7 +145,5 @@ namespace etk {
|
||||
*/
|
||||
//Archive* create(const std::u32string& _fileName);
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -5,9 +5,7 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_ARCHIVE_ZIP_H__
|
||||
#define __ETK_ARCHIVE_ZIP_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/archive/Archive.h>
|
||||
#ifdef ETK_BUILD_MINIZIP
|
||||
@ -26,10 +24,9 @@
|
||||
protected: // herited functions :
|
||||
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_DEBUG_H__
|
||||
#define __ETK_DEBUG_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/log.h>
|
||||
|
||||
@ -45,5 +44,4 @@ namespace etk {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -5,9 +5,7 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_H__
|
||||
#define __ETK_H__
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -26,4 +24,3 @@ namespace etk {
|
||||
std::string getApplicationName();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,9 +5,7 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_LOG_H__
|
||||
#define __ETK_LOG_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <sstream>
|
||||
@ -133,5 +131,3 @@ namespace etk {
|
||||
etk::log::logStream(logId, info, __LINE__, __class__, __func__, tmpStream); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
@ -5,9 +5,7 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_LOG_IOS_H__
|
||||
#define __ETK_LOG_IOS_H__
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -19,5 +17,4 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -5,83 +5,74 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_TYPES_MATRIX_H__
|
||||
#define __ETK_TYPES_MATRIX_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <vector>
|
||||
|
||||
namespace etk
|
||||
{
|
||||
template <typename T> class Matrix
|
||||
{
|
||||
namespace etk {
|
||||
template <typename T> class Matrix {
|
||||
private:
|
||||
etk::Vector2D<int32_t> m_size;
|
||||
std::vector<T> m_data;
|
||||
ivec2 m_size;
|
||||
std::vector<T> m_data;
|
||||
public:
|
||||
/*****************************************************
|
||||
* Constructor
|
||||
*****************************************************/
|
||||
Matrix(Vector2D<int32_t> size, T* defaultVal=NULL) :
|
||||
m_size(size),
|
||||
etk::Vector2D<T>(size.x* size.y)
|
||||
{
|
||||
if (NULL != defaultVal) {
|
||||
Matrix(ivec2 _size, T* _defaultVal=nullptr) :
|
||||
m_size(_size),
|
||||
etk::Vector2D<T>(_size.x.x()* _size.y()) {
|
||||
if (defaultVal != nullptr) {
|
||||
// copy all the elements
|
||||
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
|
||||
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
|
||||
// cast and set value :
|
||||
m_data[iii] = (T)defaultVal++;
|
||||
m_data[iii] = T(_defaultVal++);
|
||||
}
|
||||
} else {
|
||||
Clear();
|
||||
}
|
||||
};
|
||||
Matrix(int32_t width=0, int32_t heigh=0, T* defaultVal=NULL) :
|
||||
m_size(width, heigh),
|
||||
etk::Vector2D<T>(width*heigh)
|
||||
{
|
||||
if (NULL != defaultVal) {
|
||||
Matrix(int32_t _width=0, int32_t _heigh=0, T* _defaultVal=nullptr) :
|
||||
m_size(_width, _heigh),
|
||||
etk::Vector2D<T>(_width*_heigh) {
|
||||
if (_defaultVal != nullptr) {
|
||||
// copy all the elements
|
||||
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
|
||||
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
|
||||
// cast and set value :
|
||||
m_data[iii] = (T)defaultVal++;
|
||||
m_data[iii] = (T)_defaultVal++;
|
||||
}
|
||||
} else {
|
||||
Clear();
|
||||
}
|
||||
};
|
||||
Matrix(const Matrix<double>& obj) :
|
||||
m_size(obj.m_size.x, obj.m_size.y),
|
||||
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y)
|
||||
{
|
||||
m_size(_obj.m_size),
|
||||
etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
|
||||
// copy all the elements
|
||||
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
|
||||
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
|
||||
// cast and set value :
|
||||
m_data[iii] = (T)obj.m_data[iii];
|
||||
m_data[iii] = (T)_obj.m_data[iii];
|
||||
}
|
||||
};
|
||||
Matrix(const Matrix<float>& obj) :
|
||||
m_size(obj.m_size.x, obj.m_size.y),
|
||||
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y)
|
||||
{
|
||||
}
|
||||
Matrix(const Matrix<float>& _obj) :
|
||||
m_size(_obj.m_size),
|
||||
etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
|
||||
// copy all the elements
|
||||
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
|
||||
for(int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
|
||||
// cast and set value :
|
||||
m_data[iii] = (T)obj.m_data[iii];
|
||||
m_data[iii] = (T)_obj.m_data[iii];
|
||||
}
|
||||
};
|
||||
Matrix(const Matrix<int32_t>& obj) :
|
||||
m_size(obj.m_size.x, obj.m_size.y),
|
||||
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y)
|
||||
{
|
||||
}
|
||||
Matrix(const Matrix<int32_t>& _obj) :
|
||||
m_size(_obj.m_size.x(), _obj.m_size.y()),
|
||||
etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
|
||||
// copy all the elements
|
||||
for(int32_t iii=0; iii<=m_size.x*m_size.y; iii++) {
|
||||
for (int32_t iii=0; iii<=m_size.x()*m_size.y(); iii++) {
|
||||
// cast and set value :
|
||||
m_data[iii] = (T)obj.m_data[iii];
|
||||
m_data[iii] = (T)_obj.m_data[iii];
|
||||
}
|
||||
};
|
||||
}
|
||||
/*****************************************************
|
||||
* Destructor
|
||||
*****************************************************/
|
||||
@ -90,58 +81,53 @@ namespace etk
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const Matrix<T>& operator= (const Matrix<T>& obj )
|
||||
{
|
||||
const Matrix<T>& operator= (const Matrix<T>& _obj ) {
|
||||
// check if it was the same pointer
|
||||
if( this == &obj ) {
|
||||
if (this == &_obj ) {
|
||||
return *this;
|
||||
}
|
||||
// copy data :
|
||||
m_size = obj.m_size;
|
||||
m_data = obj.m_data;
|
||||
m_size = _obj.m_size;
|
||||
m_data = _obj.m_data;
|
||||
return *this;
|
||||
};
|
||||
const Matrix<T>& operator= (T& value)
|
||||
{
|
||||
const Matrix<T>& operator= (T& _value) {
|
||||
// set data :
|
||||
for (int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
m_data = value;
|
||||
m_data = _value;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
/*****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const Matrix<T>& obj) const
|
||||
{
|
||||
return (m_data == obj.m_data);
|
||||
bool operator== (const Matrix<T>& _obj) const {
|
||||
return (m_data == _obj.m_data);
|
||||
};
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const Matrix<T>& obj) const
|
||||
{
|
||||
return (m_data != obj.m_data);
|
||||
bool operator!= (const Matrix<T>& _obj) const {
|
||||
return (m_data != _obj.m_data);
|
||||
};
|
||||
/*****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const Matrix<T>& operator+= (const Matrix<T>& obj)
|
||||
{
|
||||
if (m_size != obj.m_size) {
|
||||
const Matrix<T>& operator+= (const Matrix<T>& _obj) {
|
||||
if (m_size != _obj.m_size) {
|
||||
//TK_CRITICAL("add 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix");
|
||||
etk::Matrix<T> tmpMatrix(std::max(m_size.x,obj.m_size.x), std::max(m_size.y,obj.m_size.y));
|
||||
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
|
||||
etk::Matrix<T> tmpMatrix(std::max(m_size.x(),_obj.m_size.x()), std::max(m_size.y(),_obj.m_size.y()));
|
||||
for (int32_t jjj=0; jjj< m_size.y(); jjj++) {
|
||||
T* tmpPointer = tmpMatrix[jjj];
|
||||
T* tmpPointerIn = (*this)[jjj];
|
||||
for (int32_t iii=0; iii< m_size.x; iii++) {
|
||||
for (int32_t iii=0; iii< m_size.x(); iii++) {
|
||||
tmpPointer[iii] = tmpPointerIn[iii];
|
||||
}
|
||||
}
|
||||
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) {
|
||||
for (int32_t jjj=0; jjj< _obj.m_size.y(); jjj++) {
|
||||
T* tmpPointer = tmpMatrix[jjj];
|
||||
T* tmpPointerIn = obj[jjj];
|
||||
for (int32_t iii=0; iii< obj.m_size.x; iii++) {
|
||||
T* tmpPointerIn = _obj[jjj];
|
||||
for (int32_t iii=0; iii< _obj.m_size.x(); iii++) {
|
||||
tmpPointer[iii] += tmpPointerIn[iii];
|
||||
}
|
||||
}
|
||||
@ -151,7 +137,7 @@ namespace etk
|
||||
} else {
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< m_data.size(); iii++) {
|
||||
m_data[iii] += obj.m_data[iii];
|
||||
m_data[iii] += _obj.m_data[iii];
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@ -159,30 +145,29 @@ namespace etk
|
||||
/*****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
Matrix<T> operator+ (const Matrix<T>& obj) {
|
||||
Matrix<T> operator+ (const Matrix<T>& _obj) {
|
||||
Matrix<T> tmpp(*this);
|
||||
tmpp += obj;
|
||||
tmpp += _obj;
|
||||
return tmpp;
|
||||
}
|
||||
/*****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const Matrix<T>& operator-= (const Matrix<T>& obj)
|
||||
{
|
||||
if (m_size != obj.m_size) {
|
||||
const Matrix<T>& operator-= (const Matrix<T>& _obj) {
|
||||
if (m_size != _obj.m_size) {
|
||||
//TK_CRITICAL("less 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix");
|
||||
etk::Matrix<T> tmpMatrix(std::max(m_size.x,obj.m_size.x), std::max(m_size.y,obj.m_size.y));
|
||||
etk::Matrix<T> tmpMatrix(std::max(m_size.x(),_obj.m_size.x()), std::max(m_size.y(),_obj.m_size.y()));
|
||||
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
|
||||
T* tmpPointer = tmpMatrix[jjj];
|
||||
T* tmpPointerIn = (*this)[jjj];
|
||||
for (int32_t iii=0; iii< m_size.x; iii++) {
|
||||
for (int32_t iii=0; iii< m_size.x(); iii++) {
|
||||
tmpPointer[iii] = tmpPointerIn[iii];
|
||||
}
|
||||
}
|
||||
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) {
|
||||
for (int32_t jjj=0; jjj< _obj.m_size.y(); jjj++) {
|
||||
T* tmpPointer = tmpMatrix[jjj];
|
||||
T* tmpPointerIn = obj[jjj];
|
||||
for (int32_t iii=0; iii< obj.m_size.x; iii++) {
|
||||
T* tmpPointerIn = _obj[jjj];
|
||||
for (int32_t iii=0; iii< _obj.m_size.x(); iii++) {
|
||||
tmpPointer[iii] -= tmpPointerIn[iii];
|
||||
}
|
||||
}
|
||||
@ -192,7 +177,7 @@ namespace etk
|
||||
} else {
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< m_data.size(); iii++) {
|
||||
m_data[iii] -= obj.m_data[iii];
|
||||
m_data[iii] -= _obj.m_data[iii];
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@ -200,27 +185,26 @@ namespace etk
|
||||
/*****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
Matrix<T> operator- (const Matrix<T>& obj) {
|
||||
Matrix<T> operator- (const Matrix<T>& _obj) {
|
||||
Matrix<T> tmpp(*this);
|
||||
tmpp += obj;
|
||||
tmpp += _obj;
|
||||
return tmpp;
|
||||
}
|
||||
/*****************************************************
|
||||
* *= operator
|
||||
*****************************************************/
|
||||
const Matrix<T>& operator*= (const Matrix<T>& obj)
|
||||
{
|
||||
if( m_size.x != obj.m_size.y
|
||||
|| m_size.y != obj.m_size.x) {
|
||||
const Matrix<T>& operator*= (const Matrix<T>& _obj) {
|
||||
if( m_size.x() != _obj.m_size.y()
|
||||
|| m_size.y() != _obj.m_size.x()) {
|
||||
//TK_CRITICAL("Error while multipliying 2 matrix with different size ==> impossible case ...");
|
||||
return *this;
|
||||
}
|
||||
etk::Matrix<T> tmpMatrix(m_size);
|
||||
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) {
|
||||
for (int32_t iii=0; iii< obj.m_size.x; iii++) {
|
||||
for (int32_t jjj=0; jjj< _obj.m_size.y(); jjj++) {
|
||||
for (int32_t iii=0; iii< _obj.m_size.x(); iii++) {
|
||||
T tmpVal = 0;
|
||||
for (int32_t kkk=0; kkk< obj.m_size.x; kkk++) {
|
||||
tmpVal += (*this)[jjj][iii+kkk] * obj[jjj+kkk][iii];
|
||||
for (int32_t kkk=0; kkk< _obj.m_size.x(); kkk++) {
|
||||
tmpVal += (*this)[jjj][iii+kkk] * _obj[jjj+kkk][iii];
|
||||
}
|
||||
tmpMatrix[jjj][iii] = tmpVal;
|
||||
}
|
||||
@ -232,25 +216,25 @@ namespace etk
|
||||
/*****************************************************
|
||||
* * operator
|
||||
*****************************************************/
|
||||
Matrix<T> operator* (const Matrix<T>& obj) {
|
||||
Matrix<T> operator* (const Matrix<T>& _obj) {
|
||||
Matrix tmpp(*this);
|
||||
tmpp *= obj;
|
||||
tmpp *= _obj;
|
||||
return tmpp;
|
||||
}
|
||||
/*****************************************************
|
||||
* [] operator
|
||||
*****************************************************/
|
||||
const T* operator[] (int32_t line) const {
|
||||
return &m_data[line*m_size.x];
|
||||
const T* operator[] (int32_t _line) const {
|
||||
return &m_data[_line*m_size.x()];
|
||||
}
|
||||
T* operator[] (int32_t line) {
|
||||
return &m_data[line*m_size.x];
|
||||
T* operator[] (int32_t _line) {
|
||||
return &m_data[_line*m_size.x()];
|
||||
}
|
||||
/*****************************************************
|
||||
* () operator
|
||||
*****************************************************/
|
||||
T& operator () (int32_t line, int32_t colomn) {
|
||||
return m_data[line*m_size.x + colomn];
|
||||
T& operator () (int32_t _line, int32_t _colomn) {
|
||||
return m_data[_line*m_size.x() + _colomn];
|
||||
}
|
||||
/*****************************************************
|
||||
* - operator
|
||||
@ -268,12 +252,11 @@ namespace etk
|
||||
* @ brief Transpose Matrix
|
||||
* @ return the transpose matrix
|
||||
*/
|
||||
Matrix<T> transpose()
|
||||
{
|
||||
Matrix<T> transpose() {
|
||||
// create a matrix with the inverted size
|
||||
Matrix<T> tmpMatrix(m_size.x, m_size.y);
|
||||
for (int32_t jjj=0; jjj< m_size.y; jjj++) {
|
||||
for (int32_t iii=0; iii< m_size.x; iii++) {
|
||||
Matrix<T> tmpMatrix(m_size);
|
||||
for (int32_t jjj=0; jjj< m_size.y(); jjj++) {
|
||||
for (int32_t iii=0; iii< m_size.x(); iii++) {
|
||||
tmpMatrix(jjj,iii) = (*this)(iii,jjj);
|
||||
}
|
||||
}
|
||||
@ -281,31 +264,29 @@ namespace etk
|
||||
};
|
||||
/**
|
||||
* @ brief Create a convolution on the matrix : set convolution on the lines
|
||||
* @ param[in] obj The convolution operator
|
||||
* @ param[in] _obj The convolution operator
|
||||
* @ return the value of the convolution
|
||||
*/
|
||||
Matrix<T>& convolution(Matrix<T>& obj)
|
||||
{
|
||||
Matrix<T>& convolution(Matrix<T>& _obj) {
|
||||
Matrix<T> tmppp(1,1);
|
||||
// TODO : ...
|
||||
return tmppp;
|
||||
};
|
||||
/**
|
||||
* @ brief generate a devide of the curent Matrix with the specify power of 2
|
||||
* @ param[in] decalage The power of 2 of the division
|
||||
* @ param[in] _decalage The power of 2 of the division
|
||||
* @ return the result
|
||||
*/
|
||||
Matrix<T>& fix(int32_t decalage)
|
||||
{
|
||||
Matrix<T>& fix(int32_t _decalage) {
|
||||
Matrix<T> tmppp(m_size);
|
||||
T tmpVal = 0;
|
||||
for(int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
tmpVal = m_data[iii];
|
||||
if (tmpVal < 0 && (tmpVal & ~(~0 << decalage))) {
|
||||
tmpVal = tmpVal >> decalage;
|
||||
if (tmpVal < 0 && (tmpVal & ~(~0 << _decalage))) {
|
||||
tmpVal = tmpVal >> _decalage;
|
||||
tmpVal++;
|
||||
} else {
|
||||
tmpVal = tmpVal >> decalage;
|
||||
tmpVal = tmpVal >> _decalage;
|
||||
}
|
||||
tmppp.m_data[iii] = tmpVal;
|
||||
}
|
||||
@ -313,27 +294,25 @@ namespace etk
|
||||
};
|
||||
/**
|
||||
* @ brief generate a devide of the curent Matrix with the specify power of 2
|
||||
* @ param[in] decalage The power of 2 of the division
|
||||
* @ param[in] _decalage The power of 2 of the division
|
||||
* @ return the result
|
||||
*/
|
||||
Matrix<T>& round(int32_t decalage)
|
||||
{
|
||||
Matrix<T>& round(int32_t _decalage) {
|
||||
Matrix<T> tmppp(m_size);
|
||||
for(int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
tmppp.m_data[iii] = ( m_data[iii]+(1<<(decalage-1)) ) >> decalage;
|
||||
tmppp.m_data[iii] = ( m_data[iii]+(1<<(_decalage-1)) ) >> _decalage;
|
||||
}
|
||||
return tmppp;
|
||||
};
|
||||
/**
|
||||
* @ brief Generate a resised matrix
|
||||
* @ param[in] size new output size
|
||||
* @ param[in] _size new output size
|
||||
* @ return Te resied matrix
|
||||
*/
|
||||
Matrix<T>& resize(etk::Vector2D<int32_t> size)
|
||||
{
|
||||
Matrix<T> tmppp(size);
|
||||
for(int32_t iii=0; iii<m_data.m_size.x && iii<tmppp.m_size.x; iii++) {
|
||||
for(int32_t jjj=0; jjj<m_data.m_size.y && jjj<tmppp.m_size.y; jjj++) {
|
||||
Matrix<T>& resize(etk::Vector2D<int32_t> _size) {
|
||||
Matrix<T> tmppp(_size);
|
||||
for(int32_t iii=0; iii<m_data.m_size.x() && iii<tmppp.m_size.x(); iii++) {
|
||||
for(int32_t jjj=0; jjj<m_data.m_size.y() && jjj<tmppp.m_size.y(); jjj++) {
|
||||
tmppp(iii,jjj) = (*this)(iii,jjj);
|
||||
}
|
||||
}
|
||||
@ -341,27 +320,26 @@ namespace etk
|
||||
};
|
||||
/**
|
||||
* @brief Select element in the matrix from a list of element Ids
|
||||
* @param[in] np Width of the output matrix
|
||||
* @param[in] p List pointer of x
|
||||
* @param[in] np Heigh of the output matrix
|
||||
* @param[in] q List pointer of y
|
||||
* @param[in] _np Width of the output matrix
|
||||
* @param[in] _p List pointer of x
|
||||
* @param[in] _np Heigh of the output matrix
|
||||
* @param[in] _q List pointer of y
|
||||
* @return the new matrix
|
||||
*/
|
||||
Matrix<T>& select(int32_t np, int32_t *p, int32_t nq, int32_t *q)
|
||||
{
|
||||
if (np < 1 || nq < 1) {
|
||||
Matrix<T>& select(int32_t _np, int32_t* _p, int32_t _nq, int32_t* _q) {
|
||||
if (_np < 1 || _nq < 1) {
|
||||
TK_WARNING("bad index array sizes");
|
||||
}
|
||||
Matrix<T> tmppp(np,nq);
|
||||
for (int32_t iii=0; iii<np; iii++) {
|
||||
for (int32_t jjj=0; jjj<nq; jjj++) {
|
||||
if( p[i] < 0
|
||||
|| p[i] >= m_size.x
|
||||
|| q[i] < 0
|
||||
|| q[i] >= m_size.y) {
|
||||
Matrix<T> tmppp(_np, _nq);
|
||||
for (int32_t iii=0; iii<_np; iii++) {
|
||||
for (int32_t jjj=0; jjj<_nq; jjj++) {
|
||||
if( _p[i] < 0
|
||||
|| _p[i] >= m_size.x()
|
||||
|| _q[i] < 0
|
||||
|| _q[i] >= m_size.y()) {
|
||||
TK_WARNING("bad index arrays");
|
||||
}
|
||||
tmppp(iii,jjj) = (*this)(p[i],q[j]);
|
||||
tmppp(iii,jjj) = (*this)(_p[i],_q[j]);
|
||||
}
|
||||
}
|
||||
return tmppp;
|
||||
@ -379,14 +357,13 @@ namespace etk
|
||||
* x x x x x
|
||||
* </pre>
|
||||
*/
|
||||
void clearUpperTriangle()
|
||||
{
|
||||
if (m_size.x != m_size.y) {
|
||||
void clearUpperTriangle() {
|
||||
if (m_size.x() != m_size.y()) {
|
||||
TK_WARNING("better to do with square Matrix");
|
||||
}
|
||||
for (int32_t iii=0; iii<m_size.x; iii++) {
|
||||
for (int32_t jjj=iii+1; jjj<m_size.y; jjj++)
|
||||
m_data[iii*m_size.x + jjj] = 0;
|
||||
for (int32_t iii=0; iii<m_size.x(); iii++) {
|
||||
for (int32_t jjj=iii+1; jjj<m_size.y(); jjj++)
|
||||
m_data[iii*m_size.x() + jjj] = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -400,41 +377,39 @@ namespace etk
|
||||
* 0 0 0 0 x
|
||||
* </pre>
|
||||
*/
|
||||
void clearLowerTriangle()
|
||||
{
|
||||
if (m_size.x != m_size.y) {
|
||||
void clearLowerTriangle() {
|
||||
if (m_size.x() != m_size.y()) {
|
||||
TK_WARNING("better to do with square Matrix");
|
||||
}
|
||||
for (int32_t iii=0; iii<m_size.x; iii++) {
|
||||
for (int32_t jjj=0; jjj<m_size.y && jjj<iii; jjj++)
|
||||
m_data[iii*m_size.x + jjj] = 0;
|
||||
for (int32_t iii=0; iii<m_size.x(); iii++) {
|
||||
for (int32_t jjj=0; jjj<m_size.y() && jjj<iii; jjj++)
|
||||
m_data[iii*m_size.x() + jjj] = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Generate a compleate random Matrix.
|
||||
* @param[in] range The min/max value of the random Generation [-range..range].
|
||||
* @param[in] _range The min/max value of the random Generation [-range..range].
|
||||
*/
|
||||
void makeRandom(float range)
|
||||
{
|
||||
void makeRandom(float _range) {
|
||||
for(int32_t iii=0; iii<m_data.size(); iii++) {
|
||||
m_data[iii] = (T)etk::tool::frand(-range, range);
|
||||
m_data[iii] = (T)etk::tool::frand(-_range, _range);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Return the maximum of the diff for this Matrix.
|
||||
* @param[in] input The compared Matix.
|
||||
* @param[in] _input The compared Matix.
|
||||
* @return The absolute max value.
|
||||
*/
|
||||
T maxDifference(const Matrix<T>& input) {
|
||||
if (m_size != input.m_size)
|
||||
T maxDifference(const Matrix<T>& _input) {
|
||||
if (m_size != _input.m_size)
|
||||
TK_WARNING("better to do with same size Matrix");
|
||||
}
|
||||
T max = 0;
|
||||
for(int32_t iii = 0;
|
||||
iii < m_data.size() && iii < input.m_data.size();
|
||||
iii < m_data.size() && iii < _input.m_data.size();
|
||||
++iii) {
|
||||
T diff = m_data[iii] - input.m_data[iii];
|
||||
T diff = m_data[iii] - _input.m_data[iii];
|
||||
if (diff<0) {
|
||||
diff = -diff;
|
||||
}
|
||||
@ -449,25 +424,23 @@ namespace etk
|
||||
*/
|
||||
void clear() {
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< m_size.x*m_size.y; iii++) {
|
||||
for (int32_t iii=0; iii< m_size.x()*m_size.y(); iii++) {
|
||||
m_data[iii] = (T)0;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Set the diagonal at 1
|
||||
*/
|
||||
void identity()
|
||||
{
|
||||
void identity() {
|
||||
// copy data for the same size :
|
||||
for (int32_t iii=0; iii< std::mim(m_size.x, m_size.y); iii++) {
|
||||
for (int32_t iii=0; iii< std::mim(m_size.x(), m_size.y()); iii++) {
|
||||
(*this)(iii,iii) = (T)1;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Clear and set the diagonal at 1
|
||||
*/
|
||||
void eye()
|
||||
{
|
||||
void eye() {
|
||||
clear();
|
||||
identity();
|
||||
};
|
||||
@ -475,16 +448,13 @@ namespace etk
|
||||
* @brief Get the size of the current Matrix.
|
||||
* @return Dimention of the matrix
|
||||
*/
|
||||
Vector2D<int32_t> size()
|
||||
{
|
||||
Vector2D<int32_t> size() {
|
||||
return m_size;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// To siplify the writing of the code ==> this is not compatible with GLSL ...
|
||||
typedef etk::Matrix<float> mat;
|
||||
typedef etk::Matrix<int32_t> imat;
|
||||
typedef etk::Matrix<uint32_t> uimat;
|
||||
|
||||
#endif
|
||||
|
@ -6,8 +6,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_TYPES_MATRIX2_H__
|
||||
#define __ETK_TYPES_MATRIX2_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <etk/types.h>
|
||||
@ -131,5 +130,4 @@ namespace etk {
|
||||
// simplify using of matrix ...
|
||||
typedef etk::Matrix2 mat2;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_TYPES_MATRIX4_H__
|
||||
#define __ETK_TYPES_MATRIX4_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/math/Vector3D.h>
|
||||
|
||||
@ -30,9 +29,9 @@ namespace etk {
|
||||
Matrix4();
|
||||
Matrix4(const Matrix4& _obj);
|
||||
Matrix4(float _a1, float _b1, float _c1, float _d1,
|
||||
float _a2, float _b2, float _c2, float _d2,
|
||||
float _a3, float _b3, float _c3, float _d3,
|
||||
float _a4, float _b4, float _c4, float _d4);
|
||||
float _a2, float _b2, float _c2, float _d2,
|
||||
float _a3, float _b3, float _c3, float _d3,
|
||||
float _a4, float _b4, float _c4, float _d4);
|
||||
Matrix4(float* _obj);
|
||||
/*****************************************************
|
||||
* Destructor
|
||||
@ -154,5 +153,3 @@ typedef etk::Matrix4 mat4;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_TYPES_PLANE_H__
|
||||
#define __ETK_TYPES_PLANE_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <vector>
|
||||
@ -207,7 +206,6 @@ namespace etk {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -9,8 +9,7 @@
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_MATH_VECTOR2D_H__
|
||||
#define __ETK_MATH_VECTOR2D_H__
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@ -425,5 +424,5 @@ namespace etk {
|
||||
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec2 >& _obj);
|
||||
//! @previous
|
||||
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec2 >& _obj);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_MATH_VECTOR3D_H__
|
||||
#define __ETK_MATH_VECTOR3D_H__
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@ -498,7 +497,6 @@ namespace etk {
|
||||
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec3>& _obj);
|
||||
//! @previous
|
||||
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec3>& _obj);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,9 +8,6 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_MATH_VECTOR4D_H__
|
||||
#define __ETK_MATH_VECTOR4D_H__
|
||||
|
||||
#include <math.h>
|
||||
#ifdef ETK_BUILD_LINEARMATH
|
||||
#include <LinearMath/btScalar.h>
|
||||
@ -441,7 +438,7 @@ namespace etk {
|
||||
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<float>& _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<uint32_t>& _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<bool>& _obj);
|
||||
};
|
||||
}
|
||||
|
||||
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
|
||||
typedef etk::Vector4D<float> vec4;
|
||||
@ -451,5 +448,3 @@ typedef etk::Vector4D<uint32_t> uivec4;
|
||||
typedef etk::Vector4D<bool> bvec4;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_FILE_SYSTEM_NODE_H__
|
||||
#define __ETK_FILE_SYSTEM_NODE_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/os/FSNodeRight.h>
|
||||
|
||||
@ -892,5 +891,4 @@ namespace etk {
|
||||
std::vector<std::string> FSNodeExplodeMultiplePath(const std::string& _path);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_FILE_SYSTEM_NODE_RIGHT_H__
|
||||
#define __ETK_FILE_SYSTEM_NODE_RIGHT_H__
|
||||
#pragma once
|
||||
|
||||
namespace etk {
|
||||
class FSNodeRight {
|
||||
@ -54,7 +53,6 @@ namespace etk {
|
||||
std::string getRight() const;
|
||||
};
|
||||
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_MESSAGE_FIFO_H__
|
||||
#define __ETK_MESSAGE_FIFO_H__
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
@ -120,6 +119,5 @@ namespace etk {
|
||||
m_condition.wait_for(lock, std::chrono::microseconds(0));
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,9 +5,7 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_STD_TOOLS_H__
|
||||
#define __ETK_STD_TOOLS_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <vector>
|
||||
@ -569,5 +567,4 @@ int32_t strlen(const char32_t * _data);
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_THREAD_TOOLS_H__
|
||||
#define __ETK_THREAD_TOOLS_H__
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
|
||||
@ -74,5 +73,3 @@ namespace etk {
|
||||
int32_t getPriority(std11::thread& _thread);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_TOOL_H__
|
||||
#define __ETK_TOOL_H__
|
||||
#pragma once
|
||||
|
||||
namespace etk {
|
||||
namespace tool {
|
||||
@ -31,7 +30,6 @@ namespace etk {
|
||||
* @param[in] _val Seek value for the pseudo random system.
|
||||
*/
|
||||
void randSeek(int32_t _val);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,9 +5,7 @@
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_TYPES_H__
|
||||
#define __ETK_TYPES_H__
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -60,5 +58,3 @@ namespace std11 = std;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ def create(target, module_name):
|
||||
pass
|
||||
else:
|
||||
#TODO : Set it in a generic include system
|
||||
my_module.add_export_flag('link', "-lpthread")
|
||||
my_module.add_export_flag('link-lib', "pthread")
|
||||
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
return my_module
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __TEST_DEBUG_H__
|
||||
#define __TEST_DEBUG_H__
|
||||
#pragma once
|
||||
|
||||
#include <etk/log.h>
|
||||
|
||||
@ -45,5 +44,4 @@ namespace test {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user