[DEV] replace 'include guard' with 'pragma once'

This commit is contained in:
Edouard DUPIN 2016-02-02 21:18:54 +01:00
parent 5844516067
commit 77e7e1bf5e
25 changed files with 176 additions and 266 deletions

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_COLOR_H__ #pragma once
#define __ETK_COLOR_H__
#include <iomanip> #include <iomanip>
@ -747,5 +746,4 @@ namespace etk {
*/ */
}; };
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_HACH_H__ #pragma once
#define __ETK_HACH_H__
#undef __class__ #undef __class__
#define __class__ "etk::Hash" #define __class__ "etk::Hash"
@ -271,5 +270,3 @@ namespace etk {
#undef __class__ #undef __class__
#define __class__ NULL #define __class__ NULL
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_NOISE_H__ #pragma once
#define __ETK_NOISE_H__
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
@ -47,6 +46,5 @@ namespace etk {
~Noise(); ~Noise();
float get(int32_t _x, int32_t _y) const; float get(int32_t _x, int32_t _y) const;
}; };
}; }
#endif

View File

@ -9,8 +9,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_ARCHIVE_H__ #pragma once
#define __ETK_ARCHIVE_H__
#include <map> #include <map>
#include <mutex> #include <mutex>
@ -146,7 +145,5 @@ namespace etk {
*/ */
//Archive* create(const std::u32string& _fileName); //Archive* create(const std::u32string& _fileName);
}; };
}; }
#endif
#endif #endif

View File

@ -5,9 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_ARCHIVE_ZIP_H__
#define __ETK_ARCHIVE_ZIP_H__
#include <etk/archive/Archive.h> #include <etk/archive/Archive.h>
#ifdef ETK_BUILD_MINIZIP #ifdef ETK_BUILD_MINIZIP
@ -26,10 +24,9 @@
protected: // herited functions : protected: // herited functions :
virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it); virtual void loadFile(const std::map<std::string, ArchiveContent>::iterator& it);
}; };
}; }
}; }
#endif #endif
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_DEBUG_H__ #pragma once
#define __ETK_DEBUG_H__
#include <etk/log.h> #include <etk/log.h>
@ -45,5 +44,4 @@ namespace etk {
} \ } \
} while (0) } while (0)
#endif

View File

@ -5,9 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_H__
#define __ETK_H__
#include <string> #include <string>
@ -26,4 +24,3 @@ namespace etk {
std::string getApplicationName(); std::string getApplicationName();
} }
#endif

View File

@ -5,9 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_LOG_H__
#define __ETK_LOG_H__
#include <etk/types.h> #include <etk/types.h>
#include <sstream> #include <sstream>
@ -133,5 +131,3 @@ namespace etk {
etk::log::logStream(logId, info, __LINE__, __class__, __func__, tmpStream); \ etk::log::logStream(logId, info, __LINE__, __class__, __func__, tmpStream); \
} \ } \
} while(0) } while(0)
#endif

View File

@ -5,9 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_LOG_IOS_H__
#define __ETK_LOG_IOS_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -19,5 +17,4 @@ extern "C" {
} }
#endif #endif
#endif

View File

@ -5,83 +5,74 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_TYPES_MATRIX_H__
#define __ETK_TYPES_MATRIX_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <vector> #include <vector>
namespace etk namespace etk {
{ template <typename T> class Matrix {
template <typename T> class Matrix
{
private: private:
etk::Vector2D<int32_t> m_size; ivec2 m_size;
std::vector<T> m_data; std::vector<T> m_data;
public: public:
/***************************************************** /*****************************************************
* Constructor * Constructor
*****************************************************/ *****************************************************/
Matrix(Vector2D<int32_t> size, T* defaultVal=NULL) : Matrix(ivec2 _size, T* _defaultVal=nullptr) :
m_size(size), m_size(_size),
etk::Vector2D<T>(size.x* size.y) etk::Vector2D<T>(_size.x.x()* _size.y()) {
{ if (defaultVal != nullptr) {
if (NULL != defaultVal) {
// copy all the elements // 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 : // cast and set value :
m_data[iii] = (T)defaultVal++; m_data[iii] = T(_defaultVal++);
} }
} else { } else {
Clear(); Clear();
} }
}; };
Matrix(int32_t width=0, int32_t heigh=0, T* defaultVal=NULL) : Matrix(int32_t _width=0, int32_t _heigh=0, T* _defaultVal=nullptr) :
m_size(width, heigh), m_size(_width, _heigh),
etk::Vector2D<T>(width*heigh) etk::Vector2D<T>(_width*_heigh) {
{ if (_defaultVal != nullptr) {
if (NULL != defaultVal) {
// copy all the elements // 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 : // cast and set value :
m_data[iii] = (T)defaultVal++; m_data[iii] = (T)_defaultVal++;
} }
} else { } else {
Clear(); Clear();
} }
}; };
Matrix(const Matrix<double>& obj) : Matrix(const Matrix<double>& obj) :
m_size(obj.m_size.x, obj.m_size.y), m_size(_obj.m_size),
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y) etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
{
// copy all the elements // 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 : // 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) : Matrix(const Matrix<float>& _obj) :
m_size(obj.m_size.x, obj.m_size.y), m_size(_obj.m_size),
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y) etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
{
// copy all the elements // 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 : // 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) : Matrix(const Matrix<int32_t>& _obj) :
m_size(obj.m_size.x, obj.m_size.y), m_size(_obj.m_size.x(), _obj.m_size.y()),
etk::Vector2D<T>(obj.m_size.x* obj.m_size.y) etk::Vector2D<T>(_obj.m_size.x()* _obj.m_size.y()) {
{
// copy all the elements // 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 : // cast and set value :
m_data[iii] = (T)obj.m_data[iii]; m_data[iii] = (T)_obj.m_data[iii];
}
} }
};
/***************************************************** /*****************************************************
* Destructor * Destructor
*****************************************************/ *****************************************************/
@ -90,58 +81,53 @@ namespace etk
/***************************************************** /*****************************************************
* = assigment * = assigment
*****************************************************/ *****************************************************/
const Matrix<T>& operator= (const Matrix<T>& obj ) const Matrix<T>& operator= (const Matrix<T>& _obj ) {
{
// check if it was the same pointer // check if it was the same pointer
if( this == &obj ) { if (this == &_obj ) {
return *this; return *this;
} }
// copy data : // copy data :
m_size = obj.m_size; m_size = _obj.m_size;
m_data = obj.m_data; m_data = _obj.m_data;
return *this; return *this;
}; };
const Matrix<T>& operator= (T& value) const Matrix<T>& operator= (T& _value) {
{
// set data : // set data :
for (int32_t iii=0; iii<m_data.size(); iii++) { for (int32_t iii=0; iii<m_data.size(); iii++) {
m_data = value; m_data = _value;
} }
return *this; return *this;
}; };
/***************************************************** /*****************************************************
* == operator * == operator
*****************************************************/ *****************************************************/
bool operator== (const Matrix<T>& obj) const bool operator== (const Matrix<T>& _obj) const {
{ return (m_data == _obj.m_data);
return (m_data == obj.m_data);
}; };
/***************************************************** /*****************************************************
* != operator * != operator
*****************************************************/ *****************************************************/
bool operator!= (const Matrix<T>& obj) const bool operator!= (const Matrix<T>& _obj) const {
{ return (m_data != _obj.m_data);
return (m_data != obj.m_data);
}; };
/***************************************************** /*****************************************************
* += operator * += operator
*****************************************************/ *****************************************************/
const Matrix<T>& operator+= (const Matrix<T>& obj) const Matrix<T>& operator+= (const Matrix<T>& _obj) {
{ if (m_size != _obj.m_size) {
if (m_size != obj.m_size) {
//TK_CRITICAL("add 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix"); //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)); 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++) { for (int32_t jjj=0; jjj< m_size.y(); jjj++) {
T* tmpPointer = tmpMatrix[jjj]; T* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = (*this)[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]; 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* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = obj[jjj]; T* tmpPointerIn = _obj[jjj];
for (int32_t iii=0; iii< obj.m_size.x; iii++) { for (int32_t iii=0; iii< _obj.m_size.x(); iii++) {
tmpPointer[iii] += tmpPointerIn[iii]; tmpPointer[iii] += tmpPointerIn[iii];
} }
} }
@ -151,7 +137,7 @@ namespace etk
} else { } else {
// copy data for the same size : // copy data for the same size :
for (int32_t iii=0; iii< m_data.size(); iii++) { 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; return *this;
@ -159,30 +145,29 @@ namespace etk
/***************************************************** /*****************************************************
* + operator * + operator
*****************************************************/ *****************************************************/
Matrix<T> operator+ (const Matrix<T>& obj) { Matrix<T> operator+ (const Matrix<T>& _obj) {
Matrix<T> tmpp(*this); Matrix<T> tmpp(*this);
tmpp += obj; tmpp += _obj;
return tmpp; return tmpp;
} }
/***************************************************** /*****************************************************
* -= operator * -= operator
*****************************************************/ *****************************************************/
const Matrix<T>& operator-= (const Matrix<T>& obj) const Matrix<T>& operator-= (const Matrix<T>& _obj) {
{ if (m_size != _obj.m_size) {
if (m_size != obj.m_size) {
//TK_CRITICAL("less 2 Matrix with différent size ... ==> generate the max size of all the 2 matrix"); //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++) { for (int32_t jjj=0; jjj< m_size.y; jjj++) {
T* tmpPointer = tmpMatrix[jjj]; T* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = (*this)[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]; 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* tmpPointer = tmpMatrix[jjj];
T* tmpPointerIn = obj[jjj]; T* tmpPointerIn = _obj[jjj];
for (int32_t iii=0; iii< obj.m_size.x; iii++) { for (int32_t iii=0; iii< _obj.m_size.x(); iii++) {
tmpPointer[iii] -= tmpPointerIn[iii]; tmpPointer[iii] -= tmpPointerIn[iii];
} }
} }
@ -192,7 +177,7 @@ namespace etk
} else { } else {
// copy data for the same size : // copy data for the same size :
for (int32_t iii=0; iii< m_data.size(); iii++) { 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; return *this;
@ -200,27 +185,26 @@ namespace etk
/***************************************************** /*****************************************************
* - operator * - operator
*****************************************************/ *****************************************************/
Matrix<T> operator- (const Matrix<T>& obj) { Matrix<T> operator- (const Matrix<T>& _obj) {
Matrix<T> tmpp(*this); Matrix<T> tmpp(*this);
tmpp += obj; tmpp += _obj;
return tmpp; return tmpp;
} }
/***************************************************** /*****************************************************
* *= operator * *= operator
*****************************************************/ *****************************************************/
const Matrix<T>& operator*= (const Matrix<T>& obj) const Matrix<T>& operator*= (const Matrix<T>& _obj) {
{ if( m_size.x() != _obj.m_size.y()
if( m_size.x != obj.m_size.y || m_size.y() != _obj.m_size.x()) {
|| m_size.y != obj.m_size.x) {
//TK_CRITICAL("Error while multipliying 2 matrix with different size ==> impossible case ..."); //TK_CRITICAL("Error while multipliying 2 matrix with different size ==> impossible case ...");
return *this; return *this;
} }
etk::Matrix<T> tmpMatrix(m_size); etk::Matrix<T> tmpMatrix(m_size);
for (int32_t jjj=0; jjj< obj.m_size.y; jjj++) { 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 iii=0; iii< _obj.m_size.x(); iii++) {
T tmpVal = 0; T tmpVal = 0;
for (int32_t kkk=0; kkk< obj.m_size.x; kkk++) { for (int32_t kkk=0; kkk< _obj.m_size.x(); kkk++) {
tmpVal += (*this)[jjj][iii+kkk] * obj[jjj+kkk][iii]; tmpVal += (*this)[jjj][iii+kkk] * _obj[jjj+kkk][iii];
} }
tmpMatrix[jjj][iii] = tmpVal; tmpMatrix[jjj][iii] = tmpVal;
} }
@ -232,25 +216,25 @@ namespace etk
/***************************************************** /*****************************************************
* * operator * * operator
*****************************************************/ *****************************************************/
Matrix<T> operator* (const Matrix<T>& obj) { Matrix<T> operator* (const Matrix<T>& _obj) {
Matrix tmpp(*this); Matrix tmpp(*this);
tmpp *= obj; tmpp *= _obj;
return tmpp; return tmpp;
} }
/***************************************************** /*****************************************************
* [] operator * [] operator
*****************************************************/ *****************************************************/
const T* operator[] (int32_t line) const { const T* operator[] (int32_t _line) const {
return &m_data[line*m_size.x]; return &m_data[_line*m_size.x()];
} }
T* operator[] (int32_t line) { T* operator[] (int32_t _line) {
return &m_data[line*m_size.x]; return &m_data[_line*m_size.x()];
} }
/***************************************************** /*****************************************************
* () operator * () operator
*****************************************************/ *****************************************************/
T& operator () (int32_t line, int32_t colomn) { T& operator () (int32_t _line, int32_t _colomn) {
return m_data[line*m_size.x + colomn]; return m_data[_line*m_size.x() + _colomn];
} }
/***************************************************** /*****************************************************
* - operator * - operator
@ -268,12 +252,11 @@ namespace etk
* @ brief Transpose Matrix * @ brief Transpose Matrix
* @ return the transpose matrix * @ return the transpose matrix
*/ */
Matrix<T> transpose() Matrix<T> transpose() {
{
// create a matrix with the inverted size // create a matrix with the inverted size
Matrix<T> tmpMatrix(m_size.x, m_size.y); Matrix<T> tmpMatrix(m_size);
for (int32_t jjj=0; jjj< m_size.y; jjj++) { for (int32_t jjj=0; jjj< m_size.y(); jjj++) {
for (int32_t iii=0; iii< m_size.x; iii++) { for (int32_t iii=0; iii< m_size.x(); iii++) {
tmpMatrix(jjj,iii) = (*this)(iii,jjj); tmpMatrix(jjj,iii) = (*this)(iii,jjj);
} }
} }
@ -281,31 +264,29 @@ namespace etk
}; };
/** /**
* @ brief Create a convolution on the matrix : set convolution on the lines * @ 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 * @ return the value of the convolution
*/ */
Matrix<T>& convolution(Matrix<T>& obj) Matrix<T>& convolution(Matrix<T>& _obj) {
{
Matrix<T> tmppp(1,1); Matrix<T> tmppp(1,1);
// TODO : ... // TODO : ...
return tmppp; return tmppp;
}; };
/** /**
* @ brief generate a devide of the curent Matrix with the specify power of 2 * @ 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 * @ return the result
*/ */
Matrix<T>& fix(int32_t decalage) Matrix<T>& fix(int32_t _decalage) {
{
Matrix<T> tmppp(m_size); Matrix<T> tmppp(m_size);
T tmpVal = 0; T tmpVal = 0;
for(int32_t iii=0; iii<m_data.size(); iii++) { for(int32_t iii=0; iii<m_data.size(); iii++) {
tmpVal = m_data[iii]; tmpVal = m_data[iii];
if (tmpVal < 0 && (tmpVal & ~(~0 << decalage))) { if (tmpVal < 0 && (tmpVal & ~(~0 << _decalage))) {
tmpVal = tmpVal >> decalage; tmpVal = tmpVal >> _decalage;
tmpVal++; tmpVal++;
} else { } else {
tmpVal = tmpVal >> decalage; tmpVal = tmpVal >> _decalage;
} }
tmppp.m_data[iii] = tmpVal; 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 * @ 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 * @ return the result
*/ */
Matrix<T>& round(int32_t decalage) Matrix<T>& round(int32_t _decalage) {
{
Matrix<T> tmppp(m_size); Matrix<T> tmppp(m_size);
for(int32_t iii=0; iii<m_data.size(); iii++) { 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; return tmppp;
}; };
/** /**
* @ brief Generate a resised matrix * @ brief Generate a resised matrix
* @ param[in] size new output size * @ param[in] _size new output size
* @ return Te resied matrix * @ return Te resied matrix
*/ */
Matrix<T>& resize(etk::Vector2D<int32_t> size) Matrix<T>& resize(etk::Vector2D<int32_t> _size) {
{ Matrix<T> tmppp(_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 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++) {
for(int32_t jjj=0; jjj<m_data.m_size.y && jjj<tmppp.m_size.y; jjj++) {
tmppp(iii,jjj) = (*this)(iii,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 * @brief Select element in the matrix from a list of element Ids
* @param[in] np Width of the output matrix * @param[in] _np Width of the output matrix
* @param[in] p List pointer of x * @param[in] _p List pointer of x
* @param[in] np Heigh of the output matrix * @param[in] _np Heigh of the output matrix
* @param[in] q List pointer of y * @param[in] _q List pointer of y
* @return the new matrix * @return the new matrix
*/ */
Matrix<T>& select(int32_t np, int32_t *p, int32_t nq, int32_t *q) Matrix<T>& select(int32_t _np, int32_t* _p, int32_t _nq, int32_t* _q) {
{ if (_np < 1 || _nq < 1) {
if (np < 1 || nq < 1) {
TK_WARNING("bad index array sizes"); TK_WARNING("bad index array sizes");
} }
Matrix<T> tmppp(np,nq); Matrix<T> tmppp(_np, _nq);
for (int32_t iii=0; iii<np; iii++) { for (int32_t iii=0; iii<_np; iii++) {
for (int32_t jjj=0; jjj<nq; jjj++) { for (int32_t jjj=0; jjj<_nq; jjj++) {
if( p[i] < 0 if( _p[i] < 0
|| p[i] >= m_size.x || _p[i] >= m_size.x()
|| q[i] < 0 || _q[i] < 0
|| q[i] >= m_size.y) { || _q[i] >= m_size.y()) {
TK_WARNING("bad index arrays"); TK_WARNING("bad index arrays");
} }
tmppp(iii,jjj) = (*this)(p[i],q[j]); tmppp(iii,jjj) = (*this)(_p[i],_q[j]);
} }
} }
return tmppp; return tmppp;
@ -379,14 +357,13 @@ namespace etk
* x x x x x * x x x x x
* </pre> * </pre>
*/ */
void clearUpperTriangle() void clearUpperTriangle() {
{ if (m_size.x() != m_size.y()) {
if (m_size.x != m_size.y) {
TK_WARNING("better to do with square Matrix"); TK_WARNING("better to do with square Matrix");
} }
for (int32_t iii=0; iii<m_size.x; iii++) { for (int32_t iii=0; iii<m_size.x(); iii++) {
for (int32_t jjj=iii+1; jjj<m_size.y; jjj++) for (int32_t jjj=iii+1; jjj<m_size.y(); jjj++)
m_data[iii*m_size.x + jjj] = 0; m_data[iii*m_size.x() + jjj] = 0;
} }
} }
}; };
@ -400,41 +377,39 @@ namespace etk
* 0 0 0 0 x * 0 0 0 0 x
* </pre> * </pre>
*/ */
void clearLowerTriangle() void clearLowerTriangle() {
{ if (m_size.x() != m_size.y()) {
if (m_size.x != m_size.y) {
TK_WARNING("better to do with square Matrix"); TK_WARNING("better to do with square Matrix");
} }
for (int32_t iii=0; iii<m_size.x; iii++) { for (int32_t iii=0; iii<m_size.x(); iii++) {
for (int32_t jjj=0; jjj<m_size.y && jjj<iii; jjj++) for (int32_t jjj=0; jjj<m_size.y() && jjj<iii; jjj++)
m_data[iii*m_size.x + jjj] = 0; m_data[iii*m_size.x() + jjj] = 0;
} }
} }
}; };
/** /**
* @brief Generate a compleate random Matrix. * @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++) { 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. * @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. * @return The absolute max value.
*/ */
T maxDifference(const Matrix<T>& input) { T maxDifference(const Matrix<T>& _input) {
if (m_size != input.m_size) if (m_size != _input.m_size)
TK_WARNING("better to do with same size Matrix"); TK_WARNING("better to do with same size Matrix");
} }
T max = 0; T max = 0;
for(int32_t iii = 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) { ++iii) {
T diff = m_data[iii] - input.m_data[iii]; T diff = m_data[iii] - _input.m_data[iii];
if (diff<0) { if (diff<0) {
diff = -diff; diff = -diff;
} }
@ -449,25 +424,23 @@ namespace etk
*/ */
void clear() { void clear() {
// copy data for the same size : // 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; m_data[iii] = (T)0;
} }
}; };
/** /**
* @brief Set the diagonal at 1 * @brief Set the diagonal at 1
*/ */
void identity() void identity() {
{
// copy data for the same size : // 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; (*this)(iii,iii) = (T)1;
} }
}; };
/** /**
* @brief Clear and set the diagonal at 1 * @brief Clear and set the diagonal at 1
*/ */
void eye() void eye() {
{
clear(); clear();
identity(); identity();
}; };
@ -475,16 +448,13 @@ namespace etk
* @brief Get the size of the current Matrix. * @brief Get the size of the current Matrix.
* @return Dimention of the matrix * @return Dimention of the matrix
*/ */
Vector2D<int32_t> size() Vector2D<int32_t> size() {
{
return m_size; return m_size;
}; };
}; };
}; }
// To siplify the writing of the code ==> this is not compatible with GLSL ... // To siplify the writing of the code ==> this is not compatible with GLSL ...
typedef etk::Matrix<float> mat; typedef etk::Matrix<float> mat;
typedef etk::Matrix<int32_t> imat; typedef etk::Matrix<int32_t> imat;
typedef etk::Matrix<uint32_t> uimat; typedef etk::Matrix<uint32_t> uimat;
#endif

View File

@ -6,8 +6,7 @@
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#ifndef __ETK_TYPES_MATRIX2_H__ #pragma once
#define __ETK_TYPES_MATRIX2_H__
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
#include <etk/types.h> #include <etk/types.h>
@ -131,5 +130,4 @@ namespace etk {
// simplify using of matrix ... // simplify using of matrix ...
typedef etk::Matrix2 mat2; typedef etk::Matrix2 mat2;
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_TYPES_MATRIX4_H__ #pragma once
#define __ETK_TYPES_MATRIX4_H__
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
@ -154,5 +153,3 @@ typedef etk::Matrix4 mat4;
#endif #endif
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_TYPES_PLANE_H__ #pragma once
#define __ETK_TYPES_PLANE_H__
#include <etk/debug.h> #include <etk/debug.h>
#include <vector> #include <vector>
@ -207,7 +206,6 @@ namespace etk {
return *this; return *this;
} }
}; };
}; }
#endif

View File

@ -9,8 +9,7 @@
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_MATH_VECTOR2D_H__ #pragma once
#define __ETK_MATH_VECTOR2D_H__
#include <math.h> #include <math.h>
@ -425,5 +424,5 @@ namespace etk {
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec2 >& _obj); std::ostream& operator <<(std::ostream& _os, const std::vector<uivec2 >& _obj);
//! @previous //! @previous
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec2 >& _obj); std::ostream& operator <<(std::ostream& _os, const std::vector<bvec2 >& _obj);
}; }
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_MATH_VECTOR3D_H__ #pragma once
#define __ETK_MATH_VECTOR3D_H__
#include <math.h> #include <math.h>
@ -498,7 +497,6 @@ namespace etk {
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec3>& _obj); std::ostream& operator <<(std::ostream& _os, const std::vector<uivec3>& _obj);
//! @previous //! @previous
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec3>& _obj); std::ostream& operator <<(std::ostream& _os, const std::vector<bvec3>& _obj);
}; }
#endif

View File

@ -8,9 +8,6 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_MATH_VECTOR4D_H__
#define __ETK_MATH_VECTOR4D_H__
#include <math.h> #include <math.h>
#ifdef ETK_BUILD_LINEARMATH #ifdef ETK_BUILD_LINEARMATH
#include <LinearMath/btScalar.h> #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<float>& _obj);
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<uint32_t>& _obj); std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<uint32_t>& _obj);
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<bool>& _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... // To siplify the writing of the code ==> this permit to have the same name with the glsl language...
typedef etk::Vector4D<float> vec4; typedef etk::Vector4D<float> vec4;
@ -451,5 +448,3 @@ typedef etk::Vector4D<uint32_t> uivec4;
typedef etk::Vector4D<bool> bvec4; typedef etk::Vector4D<bool> bvec4;
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_FILE_SYSTEM_NODE_H__ #pragma once
#define __ETK_FILE_SYSTEM_NODE_H__
#include <etk/os/FSNodeRight.h> #include <etk/os/FSNodeRight.h>
@ -892,5 +891,4 @@ namespace etk {
std::vector<std::string> FSNodeExplodeMultiplePath(const std::string& _path); std::vector<std::string> FSNodeExplodeMultiplePath(const std::string& _path);
}; };
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_FILE_SYSTEM_NODE_RIGHT_H__ #pragma once
#define __ETK_FILE_SYSTEM_NODE_RIGHT_H__
namespace etk { namespace etk {
class FSNodeRight { class FSNodeRight {
@ -54,7 +53,6 @@ namespace etk {
std::string getRight() const; std::string getRight() const;
}; };
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj); std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);
}; }
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_MESSAGE_FIFO_H__ #pragma once
#define __ETK_MESSAGE_FIFO_H__
#include <mutex> #include <mutex>
#include <vector> #include <vector>
@ -120,6 +119,5 @@ namespace etk {
m_condition.wait_for(lock, std::chrono::microseconds(0)); m_condition.wait_for(lock, std::chrono::microseconds(0));
}; };
}; };
}; }
#endif

View File

@ -5,9 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_STD_TOOLS_H__
#define __ETK_STD_TOOLS_H__
#include <etk/types.h> #include <etk/types.h>
#include <vector> #include <vector>
@ -569,5 +567,4 @@ int32_t strlen(const char32_t * _data);
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#endif #endif
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_THREAD_TOOLS_H__ #pragma once
#define __ETK_THREAD_TOOLS_H__
#include <thread> #include <thread>
@ -74,5 +73,3 @@ namespace etk {
int32_t getPriority(std11::thread& _thread); int32_t getPriority(std11::thread& _thread);
} }
} }
#endif

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __ETK_TOOL_H__ #pragma once
#define __ETK_TOOL_H__
namespace etk { namespace etk {
namespace tool { namespace tool {
@ -31,7 +30,6 @@ namespace etk {
* @param[in] _val Seek value for the pseudo random system. * @param[in] _val Seek value for the pseudo random system.
*/ */
void randSeek(int32_t _val); void randSeek(int32_t _val);
}; }
}; }
#endif

View File

@ -5,9 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
#pragma once
#ifndef __ETK_TYPES_H__
#define __ETK_TYPES_H__
#include <iostream> #include <iostream>
@ -60,5 +58,3 @@ namespace std11 = std;
#endif #endif
#endif #endif
#endif

View File

@ -106,7 +106,7 @@ def create(target, module_name):
pass pass
else: else:
#TODO : Set it in a generic include system #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__)) my_module.add_path(tools.get_current_path(__file__))
return my_module return my_module

View File

@ -8,8 +8,7 @@
#include <etk/types.h> #include <etk/types.h>
#ifndef __TEST_DEBUG_H__ #pragma once
#define __TEST_DEBUG_H__
#include <etk/log.h> #include <etk/log.h>
@ -45,5 +44,4 @@ namespace test {
} \ } \
} while (0) } while (0)
#endif