📄 lumatrix.hpp
字号:
// lumatrix.hpp// A matrix definition for matrices in A = (P)LU form.// The matrix is in a packed format occupying the same space as// a regular matrix.// Methods are provided to obtain the matrices P L and U if desired.// Includes automatic conversion to LUMatrix from Matrix,// and a coersion the other way// (c) Copyright 1995, Everett F. Carter Jr.// Permission is granted by the author to use// this software for any application provided this// copyright notice is preserved.// rcsid: @(#)lumatrix.hpp 1.11 12:38:21 5/13/96 EFC// NOTE: os << LUMatrix with TURBO C++ V1.0, causes a conversion to Matrix// then calls << Matrix// With Zortech C++ V2.1 the same statement does not cause// a conversion, LUMatrix inherits << from Matrix//// From my understanding of C++, I think the Zortech behaviour is the right one// (c) Copyright 1995, Everett F. Carter Jr.// Permission is granted by the author to use// this software for any application provided this// copyright notice is preserved.#ifndef LUMATRIX_H_#define LUMATRIX_H_ 1.11#include <barray.hpp>#include <matrix.hpp>class LUMatrix : public Matrix { private: int *pivot; int errval; void column_swap(Matrix& p, const int k1, const int k2) const; public: LUMatrix() : errval(0), pivot(NULL) {} // default constructor // constructor LUMatrix(const int r,const int c) : Matrix(r,c), errval(0) { pivot = new int[r]; } LUMatrix(const LUMatrix&); // initialization LUMatrix(const Matrix& a) : pivot(NULL) { *this = lufact(a); } // initialization from a Matrix ~LUMatrix() { delete []pivot; } // destructor LUMatrix& operator=(const LUMatrix&); // assignment#ifndef __GNUC__ operator Matrix() const; // cast TO Matrix#endif friend LUMatrix lufact(const Matrix &a); // explicit conversion friend double det(const LUMatrix &); friend double deti(const LUMatrix &, int *); friend void backsub(const LUMatrix &, BasicArray& ); friend void backt(const LUMatrix &, BasicArray& ); friend Matrix invm(const LUMatrix &); // methods to return P, L and U as separate matrices Matrix P() const; Matrix L() const; Matrix U() const;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -