#pragma once /** * @file Operators.h * * @brief Opérateurs arithmétiques pour les matrices et les vecteurs. * * Nom: William Nolin * Code permanent : NOLW76060101 * Email : william.nolin.1@ens.etsmtl.ca * */ #include "Matrix.h" #include "Vector.h" /** * Implémentation de divers opérateurs arithmétiques pour les matrices et les vecteurs. */ namespace gti320 { /** * Multiplication : Matrice * Matrice (générique) */ template Matrix<_Scalar, RowsA, ColsB> operator*(const Matrix<_Scalar, RowsA, ColsA, StorageA>& A, const Matrix<_Scalar, RowsB, ColsB, StorageB>& B) { // TODO implémenter return Matrix<_Scalar, RowsA, ColsB>(); } /** * Multiplication : Matrice (colonne) * Matrice (ligne) * * Spécialisation de l'opérateur de multiplication pour le cas où les matrices * ont un stockage à taille dynamique et où la matrice de gauche utilise un * stockage par colonnes et celle de droite un stockage par lignes. */ template Matrix<_Scalar, Dynamic, Dynamic> operator*(const Matrix<_Scalar, Dynamic, Dynamic, ColumnStorage>& A, const Matrix<_Scalar, Dynamic, Dynamic, RowStorage>& B) { // TODO : implémenter return Matrix<_Scalar, Dynamic, Dynamic>(); } /** * Multiplication : Matrice (ligne) * Matrice (colonne) * * Spécialisation de l'opérateur de multiplication pour le cas où les matrices * ont un stockage à taille dynamique et où la matrice de gauche utilise un * stockage par lignes et celle de droite un stockage par colonnes. */ template Matrix<_Scalar, Dynamic, Dynamic> operator*(const Matrix<_Scalar, Dynamic, Dynamic, RowStorage>& A, const Matrix<_Scalar, Dynamic, Dynamic, ColumnStorage>& B) { // TODO : implémenter return Matrix<_Scalar, Dynamic, Dynamic>(); } /** * Addition : Matrice + Matrice (générique) */ template Matrix<_Scalar, Rows, Cols> operator+(const Matrix<_Scalar, Rows, Cols, StorageA>& A, const Matrix<_Scalar, Rows, Cols, StorageB>& B) { // TODO : implémenter return Matrix<_Scalar, Rows, Cols>(); } /** * Addition : Matrice (colonne) + Matrice (colonne) * * Spécialisation de l'opérateur d'addition pour le cas où les deux matrices * sont stockées par colonnes. */ template Matrix<_Scalar, Dynamic, Dynamic> operator+(const Matrix<_Scalar, Dynamic, Dynamic, ColumnStorage>& A, const Matrix<_Scalar, Dynamic, Dynamic, ColumnStorage>& B) { // TODO : implémenter return Matrix<_Scalar, Dynamic, Dynamic>(); } /** * Addition : Matrice (ligne) + Matrice (ligne) * * Spécialisation de l'opérateur d'addition pour le cas où les deux matrices * sont stockées par lignes. */ template Matrix<_Scalar, Dynamic, Dynamic, RowStorage> operator+(const Matrix<_Scalar, Dynamic, Dynamic, RowStorage>& A, const Matrix<_Scalar, Dynamic, Dynamic, RowStorage>& B) { // TODO : implémenter return Matrix<_Scalar, Dynamic, Dynamic, RowStorage>(); } /** * Multiplication : Scalaire * Matrice (colonne) * * Spécialisation de l'opérateur de multiplication par un scalaire pour le * cas d'une matrice stockée par colonnes. */ template Matrix<_Scalar, _Rows, _Cols, ColumnStorage> operator*(const _Scalar& a, const Matrix<_Scalar, _Rows, _Cols, ColumnStorage>& A) { // TODO : implémenter return Matrix<_Scalar, Dynamic, Dynamic>(); } /** * Multiplication : Scalaire * Matrice (ligne) * * Spécialisation de l'opérateur de multiplication par un scalaire pour le * cas d'une matrice stockée par lignes. */ template Matrix<_Scalar, _Rows, _Cols, RowStorage> operator*(const _Scalar& a, const Matrix<_Scalar, _Rows, _Cols, RowStorage>& A) { // TODO : implémenter return Matrix<_Scalar, Dynamic, Dynamic, RowStorage>(); } /** * Multiplication : Matrice (ligne) * Vecteur * * Spécialisation de l'opérateur de multiplication matrice*vecteur pour le * cas où la matrice est représentée par lignes. */ template Vector<_Scalar, _Rows> operator*(const Matrix<_Scalar, _Rows, _Cols, RowStorage>& A, const Vector<_Scalar, _Cols>& v) { // TODO : implémenter return Vector<_Scalar, _Rows>(); } /** * Multiplication : Matrice (colonne) * Vecteur * * Spécialisation de l'opérateur de multiplication matrice*vecteur pour le * cas où la matrice est représentée par colonnes. */ template Vector<_Scalar, _Rows> operator*(const Matrix<_Scalar, _Rows, _Cols, ColumnStorage>& A, const Vector<_Scalar, _Cols>& v) { // TODO : implémenter return Vector<_Scalar, _Rows>(); } /** * Multiplication : Scalaire * Vecteur */ template Vector<_Scalar, _Rows> operator*(const _Scalar& a, const Vector<_Scalar, _Rows>& v) { // TODO : implémenter return Vector<_Scalar, _Rows>(); } /** * Addition : Vecteur + Vecteur */ template Vector<_Scalar, _RowsA> operator+(const Vector<_Scalar, _RowsA>& a, const Vector<_Scalar, _RowsB>& b) { // TODO : implémenter return Vector<_Scalar, _RowsA>(); } /** * Soustraction : Vecteur - Vecteur */ template Vector<_Scalar, _RowsA> operator-(const Vector<_Scalar, _RowsA>& a, const Vector<_Scalar, _RowsB>& b) { // TODO : implémenter return Vector<_Scalar, _RowsA>(); } }