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

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

主站蜘蛛池模板: 湘阴县| 夏津县| 察雅县| 古丈县| 仙桃市| 阳城县| 安阳县| 健康| 顺昌县| 铁力市| 云龙县| 梅州市| 高淳县| 墨江| 泸州市| 深圳市| 浑源县| 罗田县| 招远市| 阳山县| 电白县| 邵武市| 唐山市| 启东市| 锦州市| 拉萨市| 乐亭县| 全州县| 丹江口市| 涪陵区| 崇仁县| 疏附县| 勃利县| 西青区| 隆德县| 得荣县| 阜南县| 永顺县| 义马市| 荥经县| 新丰县|