---
name: "im_matinv"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/im_matinv"
---

# im\_matinv(3)

matrix operations on DOUBLEMASKs

## NAME

im\_matinv, im\_matmul, im\_mattrn - matrix operations on DOUBLEMASKs

## SYNOPSIS

**#include \<vips/vips.h\>**

**DOUBLEMASK \*im\_matinv( const DOUBLEMASK \*in, const char \*name );**

**int im\_matinv\_inplace( DOUBLEMASK \*mat );**

**DOUBLEMASK \*im\_matmul( in1, in2, name )**\
 **DOUBLEMASK \*in1, \*in2;**\
 **char \*name;**

**DOUBLEMASK \*im\_matcat( in1, in2, name )**\
 **DOUBLEMASK \*in1, \*in2;**\
 **char \*name;**

**DOUBLEMASK \*im\_mattrn( in, name )**\
 **DOUBLEMASK \*in;**\
 **char \*name;**

## DESCRIPTION

These functions treat DOUBLEMASKs as matricies, performing some of the basics of matrix algebra on them.

There should be more matrix functions: those implemeneted are just sufficient for the Gallery's calibration routines. im\_matadd, im\_matidentity should really be added.

None of these functions damage their arguments, except **[im\_matinv\_inplace(3)](/im_matinv_inplace/3.md)**.

**[im\_matinv(3)](/im_matinv/3.md)** inverts DOUBLEMASK *in*, returning a new DOUBLEMASK, called  *name*, which contains the inverse of in. If no inverse exists, NULL is returned and **[im\_error(3)](/im_error/3.md)** is called with a diagnostic message.

**[im\_matinv\_inplace(3)](/im_matinv_inplace/3.md)** is as **[im\_matinv(3)](/im_matinv/3.md)** except that it overwrites its input.

**im\_matmul()** multiples the matrices held in in1 and in2, returning their product in a matrix called name.

**im\_matcat()** returns a new matrix formed by appending matrix in2 to the end of matrix in1. The two matricies must be the same width. It is useful for combining several im\_measure()s into a single matrix.

**im\_mattrn()** transposes matrix in, returning the transpose in new matrix called name.

## NOTES

**DO NOT** use matrix inversion to solve systems of linear equations (SLEs).  The  routines **[im\_lu\_decomp(3)](/im_lu_decomp/3.md)** and **[im\_lu\_solve(3)](/im_lu_solve/3.md)** are more efficient, even for a single SLE.

## RETURN VALUE

The functions returns a new DOUBLEMASK on sucess, and NULL on failure.

**[im\_matinv\_inplace(3)](/im_matinv_inplace/3.md)** returns zero on success, and -1 on failure.

## SEE ALSO

[im\_create\_dmask(3)](/im_create_dmask/3.md), [im\_measure(3)](/im_measure/3.md), etc.  [im\_lu\_decomp(3)](/im_lu_decomp/3.md), [im\_lu\_solve(3)](/im_lu_solve/3.md)

## COPYRIGHT

National Gallery, 1992.  Tom Vajzovic, 2006

## AUTHORS

J. Cupitt\
 Tom Vajzovic
