-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bce58ee
commit cd191a1
Showing
13 changed files
with
3,577 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
project(NAlgebra) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
include_directories(header) | ||
|
||
add_library(NAlgebra STATIC | ||
source/NVector.cpp header/NVector.h | ||
header/Vector3.h | ||
source/NPMatrix.cpp header/NPMatrix.h | ||
source/AESByte.cpp header/AESByte.h | ||
source/Pixel.cpp header/Pixel.h header/typedef.h | ||
header/NAlgebra.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#ifndef MATHTOOLKIT_AESBYTE_H | ||
#define MATHTOOLKIT_AESBYTE_H | ||
|
||
#include <cmath> | ||
#include <iostream> | ||
#include <stdlib.h> | ||
#include <typedef.h> | ||
|
||
/** | ||
* @ingroup NAlgebra | ||
* @{ | ||
* @class AESByte | ||
* @copyright Dahoux Sami 2018 All rights reserved. | ||
* @date 15/10/2018 | ||
* @author samiBendou | ||
* @brief Representation of a byte in AES. | ||
* | ||
* @details Byte in AES algorithm can be seen as elements of Gallois's finite field \f$ GF(2^8) \f$. | ||
* | ||
* This class provides algebraical operation on the specific field. and | ||
* interfacing with integers primitive types. For more details go to | ||
* https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.197.pdf. | ||
* | ||
*/ | ||
|
||
class AESByte { | ||
|
||
public: | ||
|
||
friend AESByte abs(const AESByte &b); | ||
|
||
friend AESByte sqrt(const AESByte &b); | ||
|
||
// CONSTRUCTOR | ||
|
||
AESByte(char val = 0x00); | ||
|
||
AESByte(int val); | ||
|
||
AESByte(double_t val); | ||
|
||
// GETTERS | ||
|
||
uc_t val() const; | ||
|
||
// OPERATORS | ||
|
||
inline friend AESByte operator+(AESByte b1, const AESByte &b2) { | ||
b1 += b2; | ||
return b1; | ||
} | ||
|
||
inline friend AESByte operator-(AESByte b1, const AESByte &b2) { | ||
b1 -= b2; | ||
return b2; | ||
} | ||
|
||
inline friend AESByte operator-(AESByte b) { | ||
return b; | ||
} | ||
|
||
friend AESByte operator*(AESByte b1, const AESByte &b2) { | ||
b1.prod(b2); | ||
return b1; | ||
} | ||
|
||
friend AESByte operator/(AESByte b1, const AESByte &b2) { | ||
b1.div(b2); | ||
return b1; | ||
}; | ||
|
||
inline AESByte &operator+=(const AESByte &b) { | ||
return add(b); | ||
} | ||
|
||
inline AESByte &operator*=(const AESByte &b) { | ||
return add(b); | ||
} | ||
|
||
inline AESByte &operator-=(const AESByte &b) { | ||
return prod(b); | ||
} | ||
|
||
inline AESByte &operator/=(const AESByte &b) { | ||
return div(b); | ||
} | ||
|
||
inline friend bool operator==(const AESByte &b1, const AESByte &b2) { | ||
return b1._val == b2._val; | ||
} | ||
|
||
inline friend bool operator!=(const AESByte &b1, const AESByte &b2) { | ||
return b1._val != b2._val; | ||
} | ||
|
||
inline friend bool operator>(const AESByte &b1, const AESByte &b2) { | ||
return b1._val > b2._val; | ||
} | ||
|
||
inline friend bool operator<(const AESByte &b1, const AESByte &b2) { | ||
return b1._val < b2._val; | ||
} | ||
|
||
inline friend bool operator>=(const AESByte &b1, const AESByte &b2) { | ||
return b1._val >= b2._val; | ||
} | ||
|
||
inline friend bool operator<=(const AESByte &b1, const AESByte &b2) { | ||
return b1._val <= b2._val; | ||
} | ||
|
||
friend std::ostream &operator<<(std::ostream &os, const AESByte &b); | ||
|
||
private: | ||
|
||
// ALGEBRAICAL OPERATIONS | ||
|
||
AESByte &add(const AESByte &b); | ||
|
||
AESByte &prod(const AESByte &b); | ||
|
||
AESByte &div(const AESByte &b); | ||
|
||
uc_t _val; | ||
}; | ||
|
||
/** @} */ | ||
|
||
#endif //MATHTOOLKIT_AESBYTE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#ifndef MATHTOOLKITCPP_NALGEBRA_H | ||
#define MATHTOOLKITCPP_NALGEBRA_H | ||
|
||
/** | ||
* @defgroup NAlgebra Linear Algebra | ||
* @copyright Dahoux Sami 2018 All rights reserved. | ||
* @brief Linear algebra library. | ||
* @details NAlgebra is a library designed to provide intuitive and efficient use of common | ||
* linear object such as matrix or vector. | ||
* | ||
* - Linear Algebra : `+`, `*`, `/`, `%`, `inv()`, ... | ||
* | ||
* - Manipulators : `shift()`, `swap()`, ... | ||
* | ||
* - Generators : `eye()`, `ones()`, `diag()`, ... | ||
* | ||
* The library offers a code structure that allows you customization by inheritance and template specialization. | ||
* | ||
* | ||
* @page NAlgebraTutoStart Getting started | ||
* @{ | ||
* This section is a small tutorial which introduces you to `NAlgebra` objects and shows the basic of `NAlgebra` module. | ||
* | ||
* @section IntroTutoStart Introduction to MathToolKit | ||
* | ||
* @subsection NAlgebra | ||
* | ||
* @subsubsection NVector | ||
* | ||
* `NVector` objects are abstraction for mathematical vectors : | ||
* | ||
* @code{.cpp} | ||
* NVector<int> u{4, 3, -9, 9}; // initializes a vector using coordinates | ||
* std::cout << u; // displays "(4, 3, -9, 9)" | ||
* @endcode | ||
* | ||
* You can use aliases `vec_t`, `vec_char_t`, ... to use common scalar types. | ||
* Full documentation of `NVector` is available [here](https://samibendou.github.io/MathToolKitCPP/class_n_vector.html). | ||
* | ||
* **Algebraical Operations** | ||
* | ||
* Common element-wise algebraical operations are provided. Syntax is very similar to C++ primitive types : | ||
* | ||
* @code{.cpp} | ||
* vec_t u{4, 3, -9, 9}, v{1, 1, 1, 1}; | ||
* u *= 2; | ||
* std::cout << u + v; //displays "(10, 8, -16, 20)" | ||
* @endcode | ||
* | ||
* **Norm Based Euclidean Operations** | ||
* | ||
* Dot product is represented in `NAlgebra` and a set of operators are provided to calculate distance, norm, ... | ||
* | ||
* @code{.cpp} | ||
* vec_t u{1, 1, 1, 1}; | ||
* std::cout << !u; \\ return the norm of u : 2 | ||
* @endcode | ||
* | ||
* **ManipVec Manipulators** | ||
* | ||
* Common manipulators are provided such as `shift` or `swap`, eg. : | ||
* | ||
* @code{.cpp} | ||
* vec_t u{1, 2, 3}; | ||
* u.swap(0, 1).shift(1); // u = (1, 3, 2) | ||
* @endcode | ||
* | ||
* **StaticVec Static Generators** | ||
* | ||
* Generators use a syntax similar to numpy. For example : | ||
* | ||
* @code{.cpp} | ||
* vec_t u{vec_t::ones(3)}; // u = (1, 1, 1) | ||
* @endcode | ||
* | ||
* **FuncOp Function Operator** | ||
* | ||
* Function operator is used to access and eventually modify sub-ranges of a vector. | ||
* | ||
* @code{.cpp} | ||
* vec_t u{1, 2, 3} | ||
* std::cout << u(0, 1); // displays "(1, 2)" | ||
* @endcode | ||
* | ||
* It can also be chained with other operations. For example : | ||
* | ||
* @code{.cpp} | ||
* u(0, 1).fill(6); | ||
* std::cout << u(0, 2) + v(4, 6); | ||
* @endcode | ||
* @} | ||
*/ | ||
|
||
#include <NVector.h> | ||
#include <NPMatrix.h> | ||
#include <Vector3.h> | ||
#include <Pixel.h> | ||
#include <AESByte.h> | ||
#include <thirdparty.h> | ||
#include <typedef.h> | ||
|
||
|
||
#endif //MATHTOOLKITCPP_NALGEBRA_H |
Oops, something went wrong.