GithubHelp home page GithubHelp logo

jovi-wong / numerical-algebra Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 33 KB

Build a matrix class here to implement routine operation

License: GNU General Public License v3.0

C++ 98.85% Makefile 1.15%

numerical-algebra's Introduction

Numerical_Algebra

Build a matrix class here to implement routine operation In this program, I create a Matrix class to store vital information and operations. As for solving linear equations, I pack all dependent functions into below function,

sle(Matrix b, int method)

Here the method is a selective parameter can be defined as

nonpivot: corresponds 0(selective)
colpivot: corresponds 1(default)
allpivot: corresponds 2(not ready yet)

So the syntax is like

Matrix A(row1, col1, array1[]);
Matrix B(row2, 1, array2[]);
Matrix X = A.sle(B, nonpivot);

Analysis: To solve linear equations efficiently, like AX = B, where A is not singular and B is a column matrix, we must decompose A into a lower triangle matrix L and an upper matrix U. There are three ways to implement this operation, so users can choose an appropriate one when calling LU function. The LU funtion returns three Matrices in one vector, the first one stores the result, the second and third one are permutation matrices which represent row and column interchange respectively. This problem turns out to solve LUX = PBQ. Then we denote y as the solution to Ly = PBQ and UX = y. They are much simplier form, named triangle matrix, to solve.

Dependence tree as below:

Class Matrix:

----properties:
    ----unsigned int row
    ----unsigned int col
    ----vector< vector<double> > mat

----function:
    ----Matrix sle(Matrix X)
        ----Matrix lowtri_sle(Matrix y)
        ----Matrix uptri_sle(Matrix x)
        ----vector<Matrix> LU(int method)
        ----int max_index(const vector<double>& vec)
    ----print()
    ----trans()
    ----Matrix operator*(const Matrix& A)

numerical-algebra's People

Contributors

jovi-wong avatar

Stargazers

 avatar Zhen Fang avatar

Watchers

James Cloos avatar  avatar

Forkers

forzando

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.