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

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

主站蜘蛛池模板: 马龙县| 炎陵县| 湄潭县| 牟定县| 兖州市| 博湖县| 绥德县| 仁化县| 青岛市| 丰台区| 蓬溪县| 扎赉特旗| 高邮市| 揭东县| 砀山县| 涪陵区| 琼结县| 同江市| 法库县| 辽阳县| 灌云县| 芜湖县| 临海市| 新昌县| 遂川县| 明溪县| 南宫市| 水富县| 青冈县| 繁峙县| 雷波县| 南陵县| 嘉兴市| 卓尼县| 醴陵市| 冀州市| 武夷山市| 绍兴市| 荔波县| 灌云县| 嘉兴市|