官术网_书友最值得收藏!

Adjugate matrix

The adjugate of any order matrix is the transpose of its cofactor matrix. The adjugate is sometimes referred to as adjoint:

Adjugate matrix

Getting ready

We already know how to take the cofactor of a matrix and how to transpose the matrix. Implementing the adjugate function is as easy as calling our existing cofactor and transpose functions.

How to do it…

Follow these steps to implement functions which return the adjugate matrix of two, three and four dimensional square matrices:

  1. Add the declaration for adjugate for all three matrices to matrices.h:
    mat2 Adjugate(const mat2& mat);
    mat3 Adjugate(const mat3& mat);
    mat4 Adjugate(const mat4& mat);
  2. Implement all three of the adjugate functions in matrices.cpp:
    mat2 Adjugate(const mat2& mat) {
        return Transpose(Cofactor(mat));
    }
    mat3 Adjugate(const mat3& mat) {
        return Transpose(Cofactor(mat));
    }
    mat4 Adjugate(const mat4& mat) {
        return Transpose(Cofactor(mat));
    }

How it works…

The adjugate matrix utilizes two functions, which we already covered earlier: the transpose function, which swaps a matrices rows with its columns, and the cofactor function. Recall that the cofactor of element i, j is the minor of the element multiplied by How it works….

主站蜘蛛池模板: 彰化县| 广宗县| 建宁县| 佳木斯市| 岳阳市| 丁青县| 阜南县| 盐山县| 太仆寺旗| 四子王旗| 德格县| 西乌珠穆沁旗| 徐闻县| 冷水江市| 伊川县| 黑龙江省| 桃园县| 澄江县| 新民市| 修水县| 深水埗区| 云浮市| 西乡县| 固安县| 南陵县| 崇左市| 阳山县| 青铜峡市| 夏津县| 阳东县| 乐业县| 本溪| 金山区| 聊城市| 南昌县| 黄石市| 大邑县| 名山县| 江华| 彭州市| 黎川县|