How to resolve the algorithm Conjugate transpose step by step in the Wren programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Conjugate transpose step by step in the Wren programming language
Table of Contents
Problem Statement
Suppose that a matrix
M
{\displaystyle M}
contains complex numbers. Then the conjugate transpose of
M
{\displaystyle M}
is a matrix
M
H
{\displaystyle M^{H}}
containing the complex conjugates of the matrix transposition of
M
{\displaystyle M}
.
This means that row
j
{\displaystyle j}
, column
i
{\displaystyle i}
of the conjugate transpose equals the complex conjugate of row
i
{\displaystyle i}
, column
j
{\displaystyle j}
of the original matrix.
In the next list,
M
{\displaystyle M}
must also be a square matrix.
Given some matrix of complex numbers, find its conjugate transpose. Also determine if the matrix is a:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Conjugate transpose step by step in the Wren programming language
Source code in the wren programming language
import "./complex" for Complex, CMatrix
import "./fmt" for Fmt
var cm1 = CMatrix.new(
[
[Complex.new(3), Complex.new(2, 1)],
[Complex.new(2, -1), Complex.one ]
]
)
var cm2 = CMatrix.fromReals([ [1, 1, 0], [0, 1, 1], [1, 0, 1] ])
var x = 2.sqrt/2
var cm3 = CMatrix.new(
[
[Complex.new(x), Complex.new(x), Complex.zero],
[Complex.new(0, -x), Complex.new(0, x), Complex.zero],
[Complex.zero, Complex.zero, Complex.imagOne]
]
)
for (cm in [cm1, cm2, cm3]) {
System.print("Matrix:")
Fmt.mprint(cm, 5, 3)
System.print("\nConjugate transpose:")
Fmt.mprint(cm.conjTranspose, 5, 3)
System.print("\nHermitian : %(cm.isHermitian)")
System.print("Normal : %(cm.isNormal)")
System.print("Unitary : %(cm.isUnitary)")
System.print()
}
System.print("For the final example if we use a tolerance of 1e-14:")
var cm4 = cm3 * cm3.conjTranspose
var id = CMatrix.identity(3)
System.print("Unitary : %(cm4.almostEquals(id))")
You may also check:How to resolve the algorithm Sorting algorithms/Bubble sort step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the sed programming language
You may also check:How to resolve the algorithm Sierpinski carpet step by step in the Raku programming language
You may also check:How to resolve the algorithm Loops/Break step by step in the Haxe programming language
You may also check:How to resolve the algorithm Align columns step by step in the AWK programming language