LinearAlgebra(3)

✨ LinearAlgebra β€” the linear algebra besties of VolPack ✨

okay so this is LinearAlgebra(3) from the Library Functions Manual and it's literally the math squad that lives inside VolPack 🫢 they do vectors, they do matrices, they do that whole "solve the system" thing, and they're not even gatekeeping β€” you can call them from your own app too. slay.


🌸 NAME 🌸

vpIdentity3, vpIdentity4, vpNormalize3, vpMatrixVectorMult4, vpMatrixMult4, vpCrossProduct, vpSolveSystem4, vpSetVector3, vpSetVector4 β€” linear algebra routines. yes bestie, all of them, one big happy function family πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <volpack.h>

void
vpIdentity3(m_dst)
    vpMatrix3 m_dst;

void
vpIdentity4(m_dst)
    vpMatrix4 m_dst;

vpResult
vpNormalize3(v_src1)
    vpVector3 v_src1;

void
vpMatrixVectorMult4(v_dst, m_src1, v_src1)
    vpVector4 v_dst;
    vpMatrix4 m_src1;
    vpVector4 v_src1;

void
vpMatrixMult4(m_dst, m_src1, m_src2)
    vpVector4 m_dst, m_src1, m_src2;

void
vpCrossProduct(v_dst, v_src1, v_src2)
    vpVector3 v_dst, v_src1, v_src2;

vpResult
vpSolveSystem4(m_src1, b, count)
    vpMatrix4 m_src1;
    vpVector4 b[];
    int count;

void
vpSetVector3(v_dst, x, y, z)
    vpVector3 v_dst;
    double x, y, z;

void
vpSetVector4(v_dst, x, y, z, w)
    vpVector4 v_dst;
    double x, y, z, w;

πŸ¦‹ ARGUMENTS πŸ¦‹

  • m_src1, m_src2, m_dst β€” source and destination matrices. the "where it's coming from" and the "where it's going" πŸ’…
  • v_src1, v_src2, v_dst β€” source and destination vectors. same energy, but vectors.
  • b β€” array of right-hand-side vectors. it's giving "the other side of the equation" ✨
  • count β€” number of right-hand-side vectors. so, how many of those b situations we're handling.
  • x, y, z, w β€” vector components. the little numbers inside the vector, no cap.

πŸ’– DESCRIPTION πŸ’–

these routines form a simple linear algebra package used internally by VolPack, and β€” plot twist β€” they're also available as utility routines for use by your application. so like, you get to borrow them. iconic behavior honestly 🌈

vpIdentity3 assigns the identity matrix to a 3-by-3 matrix. the "who am I, I change nothing" matrix πŸͺž

vpIdentity4 assigns the identity matrix to a 4-by-4 matrix. same vibe, one dimension bigger πŸ’…

vpNormalize3 normalizes a 3-element vector (so the magnitude is 1.0). the result overwrites the source vector β€” so heads up, your original vector is gone, it got a glow-up in place πŸ‘‘

vpMatrixVectorMult4 multiplies a 4-by-4 matrix by a 4-element column vector and stores the result in the destination vector (v_dst = m . v_src). classic matrix-times-vector moment fr fr

vpMatrixMult4 multiplies two 4-by-4 matrices and stores the result in the destination matrix (m_dst = m_src1 . m_src2). two matrices walked in, one matrix walked out 😭

vpCrossProduct computes the cross product of two 3-element vectors and stores the result in the destination vector (v_dst = v_src1 x v_src2). perpendicular era πŸ¦‹

vpSolveSystem4 solves the linear system m . x = b for each right-hand-side vector in the b array. the solution vectors overwrite the vectors in the b array β€” so yeah, your b array becomes the answer key, bestie. the solution is computed using Gauss-Jordan elimination with partial pivoting and implicit scaling. that's the math being math, and it ate πŸ”₯

vpSetVector3 initializes the components of a 3-element vector (v_dst = [x, y, z]). it is a macro. yes, a macro, don't @ me.

vpSetVector4 initializes the components of a 4-element vector (v_dst = [x, y, z, w]). also a macro. twins 🫢


πŸ’€ ERRORS πŸ’€

vpNormalize3 and vpSolveSystem4 normally return VP_OK. so usually, we're chilling ✨

the following error return value is possible:

  • VPERROR_SINGULAR β€” the vector is a 0 vector (vpNormalize3 only), or the matrix is singular (vpSolveSystem4 only). this is the "math said no" error and you cannot normalize or solve your way out of it, sorry bestie 😭

πŸ‘‘ SEE ALSO πŸ‘‘

VolPack(3)


that's the whole page, no cap. this manual page came to you from VolPack β€” go be a main character with your matrices πŸ’œ πŸŽ€ ✨

πŸ“¦ where this page comes from