Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "Base.h"
  4. #include <cstddef>
  5.  
  6. namespace mat_vec {
  7.  
  8.     Vector operator*(double k, const Vector &v);
  9.  
  10.     class Vector {
  11.     public:
  12.         // Конструирует вектор размера size со значениями value
  13.         explicit Vector(size_t size, double value = 0);
  14.  
  15.         // Конструктор копирования
  16.         Vector(const Vector &src);
  17.  
  18.         // Оператор присваивания
  19.         Vector &operator=(const Vector &rhs);
  20.  
  21.         // Деструктор
  22.         ~Vector();
  23.  
  24.         // Возвращает размер вектора
  25.         size_t size() const;
  26.  
  27.         // Доступ к n-му элементу вектора
  28.         double operator[](size_t n) const;
  29.         double &operator[](size_t n);
  30.  
  31.         // L2 норма вектора
  32.         double norm() const;
  33.  
  34.         // Возвращает новый вектор, полученный нормализацией текущего (this)
  35.         Vector normalized() const;
  36.  
  37.         // Нормализует текущий вектор
  38.         void normalize();
  39.  
  40.         // Поэлементное сложение векторов
  41.         Vector operator+(const Vector &rhs) const;
  42.         Vector &operator+=(const Vector &rhs);
  43.  
  44.         // Поэлементное вычитание векторов
  45.         Vector operator-(const Vector &rhs) const;
  46.         Vector &operator-=(const Vector &rhs);
  47.  
  48.         // Поэлементное умножение векторов
  49.         Vector operator^(const Vector &rhs) const;
  50.         Vector &operator^=(const Vector &rhs);
  51.  
  52.         // Скалярное произведение
  53.         double operator*(const Vector &rhs) const;
  54.  
  55.         // Умножение всех элементов вектора на скаляр справа (v * k)
  56.         Vector operator*(double k) const;
  57.         Vector &operator*=(double k);
  58.  
  59.         // Деление всех элементов вектора на скаляр
  60.         Vector operator/(double k) const;
  61.         Vector &operator/=(double k);
  62.  
  63.         // Умножение вектора на матрицу
  64.         Vector operator*(const Matrix &mat) const;
  65.         Vector &operator*=(const Matrix &mat);
  66.  
  67.         // Поэлементное сравнение
  68.         bool operator==(const Vector &rhs) const;
  69.         bool operator!=(const Vector &rhs) const;
  70.  
  71.     private:
  72.         double *data;
  73.         size_t length;
  74.     };
  75. } // namespace mat_vec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement