Skip to content

NemoChenTW/TriangularMatrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TriangularMatrix

Using one dimension STL vector to store triangular matrix.

How to use

Prepare

  1. Decide the type of triangular matrix you need (ex. UpperTriangularMatrix).
  2. Include the header file libTriangularMatrix.h.
  3. Set the size of matrix.
  4. Initial triangular matrix.

Use

Set element

  • By using the function int setElement(unsigned int index_I, unsigned int index_J, int elementValue)

###Get element ###

  • By using the function int getElement(unsigned int index_I, unsigned int index_J)

###Show Matrix###

  • void showMatrix(bool showALL = false);
  • void showSymmetricalMatrix(bool showALL = false);
  • void showOneDimensionData();

###Show Version##

  • TriangularMatrixEnv::showVersion();

Shared Library

If you need the shared library version, download the file in directory Lib32 or Lib64.
The directory include all the file you need by using in shared library way.

##Example##

###test.cpp###

/*
 * test.cpp
 *
 *  Created on: 2014年11月4日
 *      Author: nemo
 */

#include <iostream>

#include "Include/libTriangularMatrix.h"

using namespace std;

int main()
{
    TriangularMatrix::showVersion();

    cout << "Test UpperTriangularMatrix." << endl;
    UpperTriangularMatrix UTM;
    int sizeOfMatrix = 5;
    UTM.setSizeOfMatrix(sizeOfMatrix);
    UTM.initial();

    int count = 1;
    for(int j = 0; j < sizeOfMatrix; j++)
    {
        for(int k = j; k < sizeOfMatrix; k++)
        {
            UTM.setElement(j,k,count++);
        }
    }
    UTM.showOneDimensionData();

    UTM.showMatrix();
    UTM.showSymmetricalMatrix();
    cout << endl;


    cout << "Test LowerTriangularMatrix." << endl;
    LowerTriangularMatrix LTM;

    LTM.setSizeOfMatrix(sizeOfMatrix);
    LTM.initial();

    count = 1;
    for(int j = 0; j < sizeOfMatrix; j++)
    {
        for(int k = 0; k <= j; k++)
        {
            LTM.setElement(j,k,count++);
        }
    }
    UTM.showOneDimensionData();

    LTM.showMatrix();
    LTM.showSymmetricalMatrix();
    return 0;
}

About

Using one dimension STL vector to store triangular matrix.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors