GithubHelp home page GithubHelp logo

pepe57 / vba-math-objects Goto Github PK

View Code? Open in Web Editor NEW

This project forked from beakerboy/vba-math-objects

0.0 0.0 0.0 64 KB

Object-Based mathematical operations in VBA

VBA 93.18% Visual Basic 6.0 6.82%

vba-math-objects's Introduction

Lint VBA

VBA Math Objects

An advanced object oriented math library for VBA.

Features

Upcoming

Setup

Open Microsoft Visual Basic For Applications and import each cls and bas file into a new project. Name the project VBA-Math-Objects and save it as an xlam file. Enable the addin. Within Microsoft Visual Basic For Applications, select Tools>References and ensure that "Microsoft ActiveX Data Objects x.x Library", "Microsoft Scripting Runtime", and VBA-Math-Objects is selected.

Testing

The unit tests demonstrate many ways to use each of the classes. To run the tests, Import all the modules from the testing directory into a spreadsheet, install the VBA-Unit-Testing library and type '=RunTests()' in cell A1. Ensure the Setup steps have all been successfully completed for that library.

Usage

Matrix

The library contains several different matrix factory methods:

  • ScalarMatrix(Value, m, n) - Create a matrix with m rows and n columns, with the value of Value in each element
  • Identity(m) - Create an identity matrix with M rows and columns
  • DiagonalMatrix(Vector) - Create a diagonal matrix with the elements of the supplied vector along the diagonal
  • MatrixFromJaggedArray(Array) - Create a matrix from a nested array of arrays.
  • CreateMatrix(Variant) - Create a matrix from a two-dimensional variant

Methods to create a new matrix:

Dim M as Matrix
' [0 0 0]
' [0 0 0]
Set M = ScalarMatrix(0, 2, 3)
' [1 0 0]
' [0 1 0]
' [0 0 1]
Set M = Identity(3)
' [2 3 3]
' [3 2 3]
' [3 3 2]
Set M = MatrixFromJaggedArray( _
            Array( _
                Array(2, 3, 3), _
                Array(3, 2, 3), _
                Array(3, 3, 2) _
            ) _
        )

Dim V as Vector
V = M.GetColumn(1)
' [2 0 0]
' [0 3 0]
' [0 0 3]
Set M = DiagonalMatrix(V)
Dim Mat As Variant
ReDim Mat(1 To 2, 1 To 2)
Mat(1, 1) = 1
Mat(1, 2) = 0
Mat(2, 1) = 0
Mat(2, 2) = 1
Dim M As Matrix
Set M = CreateMatrix(Mat)

The matrix class contains the following methods:

  • isDiagonal()
  • IsEqual(Matrix)
  • Add(Matrix)
  • Subtract(Matrix)
  • Multiply(Matrix)
  • ScalarMultiply(number)
  • ScalarDivide(number)
  • Transpose()
  • GetRow(Integer)
  • GetColumn(Integer)
  • AugmentRight(Matrix)
  • AugmentBelow(Matrix)
  • ReplaceRow(Integer, Vector)
  • ExcludeRow(Integer)
  • Trace()
  • GetDiagonalElements()
  • SwapColumns(Integer, Integer)
  • Submatrix(Integer, Integer, Integer, Integer)
  • Inverse()
  • ToJaggedArray()
  • ToString()

Vector

The library contains one Vector factory method:

  • CreateVector(Variant) - Create a vector from an array
Data = Array(1,2,3,4,5)

Dim V As Vector
Set V = CreateVector(Data)

vba-math-objects's People

Contributors

beakerboy 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.