albatross / Mbed 2 deprecated LAURUS_program_copy

Dependencies:   ConfigFile SDFileSystem mbed

Fork of LAURUS_program by hiroya taura

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Vector.h Source File

Vector.h

00001 #pragma once
00002 #include "mbed.h"
00003 
00004 class Matrix;
00005 
00006 class Vector {
00007     private:
00008     int dim;
00009     float* components;
00010 public:
00011     Vector(int dim);
00012     ~Vector();
00013     Vector(const Vector& v);
00014 
00015     Vector& operator=(const Vector& v);
00016     Vector operator+();
00017     Vector operator-();
00018     Vector& operator*=(float c);
00019     Vector& operator/=(float c);
00020     Vector& operator+=(const Vector& v);
00021     Vector& operator-=(const Vector& v);
00022 
00023     int Getdim(){return dim;}
00024     void SetComp(int dimNo, float val);
00025     void SetComps(float* vals);
00026     float GetNorm() const;
00027     Vector Normalize() const;
00028     Vector GetParaCompTo(Vector v);
00029     Vector GetPerpCompTo(Vector v);
00030 
00031     inline int GetDim() const {
00032         return dim;
00033     }
00034 
00035     inline const float* GetpComponents() const {
00036         return (const float*)components;
00037     }
00038 
00039     inline float GetComp(int dimNo) const {
00040         if (dimNo > dim) error("Index Out of Bounds Error !!");
00041         return components[dimNo-1];
00042     }
00043 
00044     void CleanUp();
00045 
00046 
00047     Vector& operator*=(const Matrix& m);
00048     Vector& operator*=(const Vector& m);
00049 };
00050 
00051 Vector operator+(const Vector& lhv, const Vector& rhv);
00052 Vector operator-(const Vector& lhv, const Vector& rhv);
00053 Vector Cross(const Vector& lhv, const Vector& rhv);
00054 Vector operator*(const float c, const Vector& rhv);
00055 Vector operator*(const Vector& lhv, const float c);
00056 float operator*(const Vector& lhv, const Vector& rhv);
00057