Git Product home page Git Product logo

matrix's Introduction

Matrix

Matrix class in C++ with operators implemented.

Usage

#include "matrix.h"
...

// Constructors :
Matrix<type_of_variable> matrix(int height, int width);
Matrix<type_of_variable> matrix(vector<vector<type_of_variable> > &array);
Matrix<type_of_variable> matrix();

Operators

Matrix<int> a,b,c;
int z;

c = a + b;
c = a - b;
c = a * b;
c = z * a;
c = a / z;

Example

Matrix<int> A(4,5);
Matrix<int> B(4,5);
Matrix<int> C(5,6);

Matrix<int> D = A + B;  // = A.add(B)
Matrix<int> D = A - B;  // = A.subtract(B)
Matrix<int> D = A * B;  // = A.multiply(B)
Matrix<int> D = B.dot(C);
Matrix<int> D = A.transpose();
Matrix<int> D = A.subMatrix(0,0, 2,2); // get a sub matrix of size 2x2 from coordinates 0;0 in A

A += B;
A -= B;
A *= B;

int multiplyByTwo(int x){
    return 2*x;
}

Matrix<int> D = A.applyFunction(multiplyByTwo);

// you can combine operations :

Matrix<int> D = (A+B).dot(C).applyFunction(multiplyByTwo);

std::cout << D << std::endl;

matrix's People

Contributors

omaraflak avatar

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.