Member-only story

Calculating Adjoint (Adjugate) of a NxN Matrix via MS SQL Server

DigNo Ape
3 min readDec 26, 2019

--

Purpose: Calculation of determinant, adjoint and inverse of a matrix is essential when conducting multivariate analysis. We already discussed how to calculate the determinant value of a NxN matrix previously ( click here). For this session, we will discuss how to leverage function in MS SQL Server to get the adjoint of a NxN matrix.

How to calculate Adjoint of a Matrix

Steps:

1. We will need the determinant function ([Matrix].[determinant]) we built previously ( click here) to calculate each elements of adjoint matrix and function named[Matrix].[determinant_temp_function] to redefine the row and col number after selecting the first element of each row.

2. Create a function called [Matrix].[Adjoint] to have

- Input: Matrix as table type (MatrixTableType)
— Output: Adjoint Matrix as table type (MatrixTableType)
— Define i, j, iMax, jMax, and sign to control loop to calculate each element of decreasing matrix and transpose part.

CREATE FUNCTION [Matrix].[Adjoint]
(
@input AS Matrix.MatrixTableType READONLY
)
RETURNS @output TABLE
(
i INT,
j INT,
value FLOAT
)

AS
BEGIN

DECLARE @i INT
DECLARE @j INT
DECLARE @iMAX INT
DECLARE @jMAX INT
DECLARE @sign INT
DECLARE @value_Adj FLOAT
DECLARE @table_cofactor Matrix.MatrixTableType

SET @i = 1
SET @j = 1
SET @sign = 1

SET @iMAX = (select max(i) from…

--

--

DigNo Ape
DigNo Ape

Written by DigNo Ape

我們秉持著從原人進化的精神,不斷追求智慧的累積和工具的運用來提升生產力。我們相信,每一個成員都擁有無限的潛力,透過學習和實踐,不斷成長和進步。

No responses yet