vector.h

来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C头文件 代码 · 共 53 行

H
53
字号
// ENERGY211/CME211//// vector.h - header file for Project 2//#ifndef CLASS_VECTOR	// Make sure this isn't included#define CLASS_VECTOR	// more than once#include "matrix.h"// This derived class is used to implement a column vector.// We could simply use a Matrix object with one column, but// this is more convenient.  Again, DO NOT ADD, MODIFY OR// DELETE PUBLIC DECLARATIONS!class ColVector : public Matrix {public:	// To construct a vector from an array of doubles	ColVector( int rows = 0, double *data = NULL );	// Copy constructor	ColVector( const ColVector& v );	// Conversion constructor from Matrix object with	// one column	ColVector( const Matrix& A );	// This destructor will automatically call the	// destructor for the underlying Matrix object first	~ColVector();	inline int length() const { return m_rows; }		static double norm( const ColVector& v, int p = 2 );		// If we add two vectors, or perform any other similar	// operation, we are using the operator of the Matrix	// class, the result is a Matrix.  In order to assign	// the result to a ColVector object, we need this	// overload of the assignment operator	//ColVector& operator=( const ColVector& v );	ColVector& operator=( const Matrix& v );		// The [] operator for a Matrix object returns a pointer	// to the ith row, which contains the ith element, but 	// for a column vector, we need the ith element itself.	// This redefines the [] operator accordingly.	double& operator[]( int i ) const;		ColVector operator[]( Range r ) const;	private:	int m_dummy;} ;#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?