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

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

主站蜘蛛池模板: 稷山县| 怀集县| 冀州市| 白银市| 绥棱县| 横峰县| 临沭县| 汝州市| 桑日县| 皋兰县| 来宾市| 日喀则市| 前郭尔| 万盛区| 冀州市| 仁怀市| 晋州市| 神池县| 丹东市| 弥勒县| 华亭县| 盱眙县| 盘锦市| 柏乡县| 定远县| 木里| 崇左市| 昌邑市| 海晏县| 阿克陶县| 淮北市| 福贡县| 高密市| 白城市| 禄丰县| 疏勒县| 镇平县| 南木林县| 曲沃县| 南江县| 江都市|