Skip to content

ZJUCADGeoSim/matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Aug 16, 2021
cf50538 · Aug 16, 2021

History

7 Commits
Aug 7, 2021
Aug 7, 2021
Aug 7, 2021
Aug 7, 2021
Aug 14, 2021
Aug 6, 2021
Aug 16, 2021

Repository files navigation

zjucad::matrix

What is it?

This is matrix library in C++ which provides an interface similar (or nearly identical) to Matlab/Octave. The technique is similar to Eigen.

Some most important features include:

  • matrix and vector are unified.
  • index can be integer, range, and another integer-valued vector/matrix.

If you are familiar with MATLAB, you may find that this lib can easily bring your experience in MATLAB to your C++ code.

Usage

  • Installation: One can add it as a dependency with CPM:
CPMAddPackage(
  NAME zjucad.matrix
  GITHUB_REPOSITORY ZJUCADGeoSim/matrix
  GIT_TAG v0.1.0
)

Or, just include the headers.

  • About the ":" in Matlab

In C++, use "colon()" for ":", and use "colon(beg, end)" for "beg:end".

  • A=A*B will give wrong answer

This is a common behavior of many libraries using C++ Expression Templates.

The correct way is A=temp(A*B). It should be noticed that A=A+B is correct. One can refer "Eigen: Aliasing" to understand this.

History

Jin Huang learned some about Matlab and when he was a bachelor student. Inspired by the design of mwArray in Matlab, he began to write C++ matrix library in 2001. After several rounds of code refactoring, he found the current design in 2004, and intensively applied it to all his projects, which makes the library mature enough. Now, many of his research work are still based on it.