⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.h

📁 由matlab开发的hybrid系统的描述语言
💻 H
字号:
/*	HYSDEL	Copyright (C) 1999-2002  Fabio D. Torrisi	This file is part of HYSDEL.    	HYSDEL is free software; you can redistribute it and/or	modify it under the terms of the GNU General Public	License as published by the Free Software Foundation; either	version 2 of the License, or (at your option) any later version.	HYSDEL is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU	General Public License for more details.	You should have received a copy of the GNU General Public	License along with this library; if not, write to the Free Software	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA	CONTACT INFORMATION	===================	Fabio D. Torrisi	ETH Zentrum	Physikstrasse. 3 ETL,	CH-8032 Zurich	Switzerland	mailto:torrisi@aut.ee.ethz.ch (preferred)*/#ifndef D_MATRIX#define D_MATRIX#ifndef STD_NS#define STD_NSusing namespace std;#endif#include <map>#include <string>class Expr;#include "Matrix_entry_key.h"/** simple Matrix implementation supports simple symbolic operations * through the use of the class Expr as scalar-type. * @author Dominic Jost * @author Fabio Torrisi * @description Implementation details: entries[y] is valid for 0<=y<dim_y * if row y is empty, then entries[y]==NULL, (so eintries[y][x] is not valid) * if row y contains some entrie, then entries[y][x] is valid for * 0<=x<dim_x, but may contain NULL */class Matrix {public:	Matrix();	~Matrix();	Matrix * clone() const;	void set_sparse_output(bool b) { use_sparse_output = b; }	/** checks that all entries have valid x, y coordinates	 * sets dimensions for output */	void check_dim(int y, int x);	/** set coeff in row y, column x */	void set(int y, int x, Expr * coeff);	/** get coeff in row y, column x. Return NULL if coeff not set */	Expr * get(int y, int x) const;	/** add all rows in from as new rows. x coords are not	 * modified or checked */	void concat_y(Matrix * from);	/** add matrix r to the right */	void concat_x(Matrix * r);	int get_dimy();	/** Matrix-addition */	void operator += (Matrix * add);	string to_matlab_full() const;	string to_matlab_sparse() const;	/** just a shorthand, it calls either to_matlab_full	 * or to_matlab_sparse, depending on use_sparse_output */	string to_matlab() const;private:	/** only if dim_checked the values is dim_x and dim_y are valid.	 * And only then can the matrix be output. */	bool dim_checked;	int dim_x, dim_y;	bool use_sparse_output;	/** the matrix elements: Matrix_entry_key gives the	 * position, Expr* the value */	map < Matrix_entry_key, Expr *, Matrix_entry_key > entries;	typedef map < Matrix_entry_key, Expr *,		Matrix_entry_key >::iterator entries_iter;	typedef map < Matrix_entry_key, Expr *,		Matrix_entry_key >::const_iterator const_entries_iter;	/** does the matrix have any nonzero entry? */	bool is_zeros() const;};#endif //D_MATRIX

⌨️ 快捷键说明

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