亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? vector.h

?? 這是兩個很好用的集合類
?? H
?? 第 1 頁 / 共 2 頁
字號:
///Vector.h and .cpp
#ifndef __VECTOR_H__
#define __VECTOR_H__

// System includes

#include <iostream>
#include <fstream>
#include <math.h>


namespace Flood
{

/// Forward declaration of Matrix template

template <class Type> class Matrix;

/// This template class defines a vector for general purpose use.
///
/// @see Matrix.

template <class Type>
class Vector
{

private:

   /// Size of vector.

   int size;

   /// Pointer to a Type.

   Type* vector;

public:


   // CONSTRUCTORS

   Vector(void);

   Vector(int);

   Vector(int, const Type&);

   Vector(int, const Type*);

   Vector(const Vector&);


   // ASSINGMENT OPERATOR

   Vector& operator=(const Vector&);


   // REFERENCE OPERATORS

   inline Type& operator[](const int);

   inline const Type& operator[](const int) const;

   // METHODS

   inline int getSize(void);
   inline void setSize(int);

   inline void resize(int);

   inline void fillAtRandom(void);
   inline void fillAtRandom(double, double);

   inline Type calculateMean(void);
   inline Type calculateStandardDeviation(void);

   inline Type calculateMinimum(void);
   inline Type calculateMaximum(void);

   inline int calculateMinimalIndex(void);
   inline int calculateMaximalIndex(void);

   inline double calculateNorm(void);

   inline Vector<Type> operator+(Type);
   inline Vector<Type> operator+(Vector<Type>);

   inline Vector<Type> operator-(Type);
   inline Vector<Type> operator-(Vector<Type>);

   inline Vector<Type> operator*(Type);
   inline Type dot(Vector<Type>);
   inline Vector<Type> operator*(Vector<Type>);
   inline Vector<Type> operator*(Matrix<Type>);
   inline Matrix<Type> outer(Vector<Type>);

   inline Vector<Type> operator/(Type);
   inline Vector<Type> operator/(Vector<Type>);

   inline Type* begin();
   inline Type* end();

   inline void insert(int, Vector<Type>);
   inline Vector<Type> extract(int, int);
      inline Vector<Type> assemble(Vector<Type>);

   void load(char*);
   void save(char*);

   // DESTRUCTOR

   ~Vector();
};


// CONSTRUCTORS

/// Default constructor. It creates a vector of size zero.

template <typename Type>
Vector<Type>::Vector(void) : size(0), vector(0)
{

}


/// Constructor. It creates a vector of size n, containing n copies of the default value for Type.
///
/// @param newSize Size of Vector.

template <typename Type>
Vector<Type>::Vector(int newSize) : size(newSize), vector(new Type[newSize])
{

}


/// Constructor. It creates a vector of size n, containing n copies of the type value of Type. 
///
/// @param newSize Size of Vector.
/// @param type Value of Type.

template <typename Type> Vector<Type> ::Vector(int newSize, const Type& type) 
: size(newSize), vector(new Type[newSize])
{
   for(int i = 0; i < newSize; i++)
   {
      vector[i] = type;
   }
}


/// Constructor. It creates a vector of size n, containing n copies of the type value of Type. 
///
/// @param newSize Size of Vector.
/// @param type Value of Type.

template <typename Type> Vector<Type>::Vector(int newSize, const Type* type) 
: size(newSize), vector(new Type[newSize])
{
   for(int i = 0; i < newSize; i++)
   {
      vector[i] = *type++;
   }
}


/// Copy constructor. It creates a copy of an existing Vector. 
///
/// @param oldVector Vector to be copied.

template <typename Type> Vector<Type>::Vector(const Vector<Type>& oldVector) 
: size(oldVector.size), vector(new Type[size])
{
   for(int i = 0; i < size; i++)
   {
      vector[i] = oldVector[i];
   }
}


// ASSIGNMENT OPERATORS

/// Assignment operator. It assigns to self a copy of an existing Vector.
///
/// @param oldVector Vector to be assigned.

template <typename Type>
Vector<Type>& Vector<Type>::operator=(const Vector<Type>& oldVector)
{
   if(this != &oldVector)
   {
      if(size != oldVector.size)
      {
         if(vector != 0)
         {
            delete [] (vector);
         }

         size = oldVector.size;

         vector = new Type[size];
      }

      for(int i = 0; i < size; i++)
      {
         vector[i] = oldVector[i];
      }
   }

   return(*this);
}


// REFERENCE OPERATORS

/// Reference operator. 

template <typename Type>
inline Type& Vector<Type>::operator[](const int i) 
{
   // Control sentence (if debug)

   #ifndef NDEBUG 

   if(i >= size)
   {
      std::cerr << std::endl
                << "Flood Error: Vector Template. " << std::endl
                << "Reference operator []." << std::endl
                << "Index is " << i << " and it must be less than " << size << "." << std::endl
                << std::endl;

      exit(1);
   }

   #endif

   // Return vector element

   return(vector[i]);
}


/// Reference operator. 

template <typename Type>
inline const Type& Vector<Type>::operator[](const int i) const 
{
   // Control sentence (if debug)
   
   #ifndef NDEBUG 

   if(i >= size)
   {
      std::cerr << std::endl
                << "Flood Error: Vector Template. " << std::endl
                << "Reference operator []." << std::endl
                << "Index is " << i << " and it must be less than " << size << "." << std::endl
                << std::endl;

      exit(1);
   }

   #endif

   return(vector[i]);
}


// METHODS

// int getSize(void) method

/// This method returns the number of elements in the vector. 

template <typename Type>
inline int Vector<Type>::getSize()
{
   return(size);
}


// void setSize(int) method

/// This method sets a new size in the vector.
/// It also initializes the new vector with the previous values.
///
/// @param newSize New number of elements.

template <typename Type>
inline void Vector<Type>::setSize(int newSize)
{
   vector = new Type[newSize];   size = newSize;
}


// void resize(int) method

/// This method sets a new size in the vector.
/// It also initializes the new vector with the previous values.
///
/// @param newSize New number of elements.

template <typename Type>
inline void Vector<Type>::resize(int newSize)
{
   if(newSize > size)
   {
      Vector<Type> newVector(newSize);   

      for(int i = 0; i < size; i++)
      {
        newVector[i] = vector[i];
      }

      vector = new Type[newSize];

      for(int i = 0; i < size; i++)
      {
         vector[i] = newVector[i];      
      }

      size = newSize;
   }
   else if(newSize < size)
   {      
      Vector<Type> newVector(newSize);   

      for(int i = 0; i < newSize; i++)
      {
        newVector[i] = vector[i];
      }

      vector = new Type[newSize];

      for(int i = 0; i < newSize; i++)
      {
         vector[i] = newVector[i];      
      }

      size = newSize;
   }
   else
   {
      // Do nothing
   }
}


// void fillAtRandom(void) method

/// This method assigns a random value comprised between -1 and 1 to each element in the vector. 

template <class Type>
inline void Vector<Type>::fillAtRandom(void)
{
   double random = 0.0;

   for(int i = 0; i < size; i++)
   {
      random = (double)rand()/(RAND_MAX+1.0);

      vector[i] = -1.0 + 2.0*random;
   }
}


// void fillAtRandom(double, double) method

/// This method assigns a random value comprised between a minimum and a maximum values to each element in the 
/// vector. 
///
/// @param minimum Minimum filling value.  
/// @param maximum Maximum filling value.

template <class Type>
inline void Vector<Type>::fillAtRandom(double minimum, double maximum)
{
   // Control sentence (if debug)

   #ifndef NDEBUG 

   if(minimum > maximum)
   {
      std::cerr << std::endl
                << "Flood Error: Vector Template." << std::endl 
                << "void fillAtRandom(double, double) method." << std::endl
                << "Minimum value must be less or equal than maximum value." << std::endl
                << std::endl;

      exit(1);
   }

   #endif

   double random = 0.0;

   for(int i = 0; i < size; i++)
   {
      random = (double)rand()/(RAND_MAX+1.0);

      vector[i] =  minimum + (maximum - minimum)*random;
   }
}


// Type calculateMinimum(void) method

/// This method returns the smallest element in the vector.

template <typename Type>
inline Type Vector<Type>::calculateMinimum()
{
   Type minimum = vector[0];

   for(int i = 1; i < size; i++)
   {
      if(vector[i] < minimum)
      {
         minimum = vector[i];
      }
   }
   
   return(minimum);
}


// Type calculateMaximum(void) method

/// This method returns the largest element in the vector.

template <typename Type>
inline Type Vector<Type>::calculateMaximum()
{
   Type maximum = vector[0];

   for(int i = 1; i < size; i++)
   {
      if(vector[i] > maximum)
      {
         maximum = vector[i];
      }
   }
   
   return(maximum);
}


// int calculateMinimalIndex(void) method

/// This method returns the index of the smallest element in the vector.

template <typename Type>
inline int Vector<Type>::calculateMinimalIndex()
{
   Type minimum = vector[0];
   int minimalIndex = 0;

   for(int i = 1; i < size; i++)
   {
      if(vector[i] < minimum)
      {
         minimum = vector[i];
         minimalIndex = i;
      }
   }
   
   return(minimalIndex);
}


// int calculateMaximalIndex(void) method

/// This method returns the index of the largest element in the vector.

template <typename Type>
inline int Vector<Type>::calculateMaximalIndex()
{
   Type maximum = vector[0];
   int maximalIndex = 0;

   for(int i = 1; i < size; i++)
   {
      if(vector[i] > maximum)
      {
         maximum = vector[i];
         maximalIndex = i;
      }
   }
   
   return(maximalIndex);
}


// Type calculateMean(void) method

/// This method returns the mean of the elements in the vector.

template <typename Type>
inline Type Vector<Type>::calculateMean(void)
{
   Type mean = 0;

   double sum = 0.0;

   for(int i = 0; i < size; i++)
   {
      sum += vector[i];
   }

   mean = sum/(double)size;
   
   return(mean);
}


// Type calculateStandardDeviation(void) method

/// This method returns the standard deviation of the elements in the vector.

template <typename Type>
inline Type Vector<Type>::calculateStandardDeviation(void)
{
   Type standardDeviation = 0;

   double mean = calculateMean();

   double sum = 0.0;
   
   for(int i = 0; i < size; i++)
   {
      sum += pow(vector[i] - mean, 2);
   }

   standardDeviation = sqrt(sum/(double)size);
   
   return(standardDeviation);
}


// double calculateNorm(void) method

/// This element returns the vector norm.

template <typename Type>
inline double Vector<Type>::calculateNorm()
{   // Control sentence (if debug)

   #ifndef NDEBUG 

   if(size == 0)
   {
      std::cerr << std::endl
                << "Flood Error: Vector Template." << std::endl 
                << "double calculateNorm(void) method." << std::endl
                << "Size of vector is zero." << std::endl
                << std::endl;

      exit(1);
   }

   #endif

   double norm = 0.0;

   for(int i = 0; i < size; i++)
   {
      norm += vector[i]*vector[i];
   }
   
   norm = sqrt(norm);
   
   return(norm);
}


// Vector<Type> operator + (Type) method 

/// Sum vector+scalar arithmetic operator. 

template <typename Type>
inline Vector<Type> Vector<Type>::operator + (Type scalar)
{       
   Vector<Type> sum(size);

   for(int i = 0; i < size; i++)
   {
      sum[i] = vector[i] + scalar;
   }
   
   return(sum);
}


// Vector<Type> operator + (Vector<Type>)

/// Sum vector+vector arithmetic operator.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲另类国产综合| 色综合久久久网| 欧美一区二区三区免费大片| 亚洲最大成人网4388xx| 欧美性受xxxx黑人xyx| 亚洲一二三区不卡| 欧美一区二区三区四区久久| 免费视频一区二区| 欧美一级黄色片| 国产精品一区一区三区| 国产日本一区二区| 一本高清dvd不卡在线观看| 亚洲一区在线观看网站| 制服.丝袜.亚洲.中文.综合| 韩国av一区二区三区| 亚洲国产成人午夜在线一区| 91美女在线看| 日本亚洲免费观看| 日本一区免费视频| 在线中文字幕不卡| 久久福利视频一区二区| 久久亚洲综合色| 色婷婷久久久久swag精品| 日韩一区精品字幕| 国产免费观看久久| 欧美日韩国产中文| 成人小视频在线观看| 亚洲一区二区三区视频在线播放| 日韩一二在线观看| 不卡一区二区三区四区| 午夜精品123| 国产嫩草影院久久久久| 欧美亚洲一区二区三区四区| 国产美女视频91| 亚洲在线视频一区| 久久精品亚洲国产奇米99| 91热门视频在线观看| 欧美a级一区二区| 一区二区三区日韩精品| 亚洲精品在线免费观看视频| 在线观看视频91| 成人毛片在线观看| 天堂成人免费av电影一区| 亚洲国产精品99久久久久久久久 | 欧美喷水一区二区| 国产精品中文字幕欧美| 亚洲国产一区视频| 亚洲欧美自拍偷拍| 亚洲精品在线网站| 欧美一区二区大片| 欧美亚洲禁片免费| 99国产精品久| 粉嫩绯色av一区二区在线观看 | 蜜桃在线一区二区三区| 亚洲欧美日韩国产中文在线| 久久久久久久久免费| 欧美一区二区三区的| 欧美亚洲愉拍一区二区| 国产999精品久久| 精品亚洲国产成人av制服丝袜| 亚洲一区二区美女| 一区二区三区在线影院| 国产精品第五页| 国产精品麻豆欧美日韩ww| 欧美mv和日韩mv的网站| 7777精品伊人久久久大香线蕉 | 美脚の诱脚舐め脚责91 | 欧美在线免费观看亚洲| 成人app在线观看| 懂色中文一区二区在线播放| 精品在线播放午夜| 另类专区欧美蜜桃臀第一页| 日本亚洲三级在线| 久久精品国产一区二区三区免费看 | 91蝌蚪porny| 91在线免费看| 一本到不卡精品视频在线观看 | 欧美午夜电影一区| 在线这里只有精品| 欧美男人的天堂一二区| 欧美麻豆精品久久久久久| 欧美性受xxxx黑人xyx| 欧美另类变人与禽xxxxx| 欧美日韩在线三区| 欧美狂野另类xxxxoooo| 51精品国自产在线| 日韩视频免费观看高清完整版 | 国产精品污www在线观看| 国产丝袜欧美中文另类| 日本一区二区三级电影在线观看 | 亚洲三级久久久| 亚洲精品水蜜桃| 午夜精品成人在线视频| 日本系列欧美系列| 国产原创一区二区三区| 成人黄色在线看| 色先锋资源久久综合| 欧美日韩美女一区二区| 欧美xxxx老人做受| 日本一区二区动态图| 国产精品高清亚洲| 亚洲va韩国va欧美va| 美日韩一区二区| 成人动漫视频在线| 欧美午夜影院一区| 日韩精品一区二区三区老鸭窝 | 欧美一级高清片在线观看| 精品国产一区二区三区久久影院| 久久精品欧美一区二区三区麻豆 | 欧美中文字幕久久| 精品国偷自产国产一区| 中文在线一区二区| 午夜精品一区二区三区电影天堂| 国内偷窥港台综合视频在线播放| 91亚洲国产成人精品一区二区三| 欧美日韩久久久| 中文av字幕一区| 天堂一区二区在线免费观看| 成人白浆超碰人人人人| 欧美久久久久久蜜桃| 国产亚洲va综合人人澡精品| 一区二区三区**美女毛片| 麻豆国产91在线播放| 99精品久久久久久| 日韩免费观看高清完整版 | 一区二区三区不卡视频| 国产精品综合久久| 欧美在线色视频| 中文字幕国产一区| 久久精品国产久精国产| 一本久久精品一区二区| 欧美精品一区二区高清在线观看| 亚洲精选一二三| 国产高清在线观看免费不卡| 欧美日韩精品一区二区天天拍小说| 久久久久久久久蜜桃| 奇米一区二区三区| 色综合久久久久综合99| 久久久美女毛片| 日本在线不卡一区| 在线视频你懂得一区| 国产精品拍天天在线| 激情深爱一区二区| 在线成人免费视频| 一区二区三区久久久| 成人黄色在线网站| 国产欧美一区二区精品忘忧草 | 国产91精品一区二区麻豆亚洲| 69久久夜色精品国产69蝌蚪网| 亚洲蜜臀av乱码久久精品| 国产一区二区美女| 日韩你懂的在线观看| 午夜成人免费电影| 欧美综合欧美视频| 亚洲视频小说图片| av色综合久久天堂av综合| 久久精品日韩一区二区三区| 精品在线播放免费| 欧美sm美女调教| 奇米在线7777在线精品| 在线成人av网站| 人人狠狠综合久久亚洲| 欧美一卡二卡三卡| 热久久免费视频| 91精品国产综合久久国产大片| 亚洲线精品一区二区三区 | 91香蕉视频污在线| 亚洲男人的天堂在线观看| 99久久99精品久久久久久| 国产精品福利一区二区三区| 99在线热播精品免费| 亚洲欧美综合色| 在线亚洲免费视频| 亚洲综合在线第一页| 欧美亚洲国产一区二区三区| 亚洲成人免费在线| 欧美一区午夜精品| 久久成人免费日本黄色| 久久综合九色欧美综合狠狠| 国产乱人伦精品一区二区在线观看| 久久只精品国产| 国产aⅴ精品一区二区三区色成熟| 国产欧美在线观看一区| av中文字幕亚洲| 中文字幕在线一区免费| 91丨porny丨中文| 亚洲成人福利片| 精品久久久网站| 国产成人综合视频| 136国产福利精品导航| 欧美亚洲综合一区| 久久精品99国产精品日本| 久久综合久久综合久久| 99精品久久只有精品| 水蜜桃久久夜色精品一区的特点| 欧美电影精品一区二区| 国产成人高清视频| 夜夜嗨av一区二区三区| 欧美一区二区人人喊爽| 国产成人8x视频一区二区|