How to resolve the algorithm Conjugate transpose step by step in the Common Lisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Conjugate transpose step by step in the Common Lisp 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 Common Lisp programming language

Source code in the common programming language

(defun matrix-multiply (m1 m2)
 (mapcar
  (lambda (row)
   (apply #'mapcar
    (lambda (&rest column)
     (apply #'+ (mapcar #'* row column))) m2)) m1))

(defun identity-p (m &optional (tolerance 1e-6))
 "Is m an identity matrix?"
  (loop for row in m
    for r = 1 then (1+ r) do
      (loop for col in row
        for c = 1 then (1+ c) do
          (if (eql r c)
            (unless (< (abs (- col 1)) tolerance) (return-from identity-p nil))
            (unless (< (abs col) tolerance) (return-from identity-p nil)) )))
  T )

(defun conjugate-transpose (m)
  (apply #'mapcar #'list (mapcar #'(lambda (r) (mapcar #'conjugate r)) m)) )

(defun hermitian-p (m)
  (equalp m (conjugate-transpose m)))

(defun normal-p (m)
  (let ((m* (conjugate-transpose m)))
    (equalp (matrix-multiply m m*) (matrix-multiply m* m)) ))
    
(defun unitary-p (m)
  (identity-p (matrix-multiply m (conjugate-transpose m))) )


  

You may also check:How to resolve the algorithm Julia set step by step in the Perl programming language
You may also check:How to resolve the algorithm Median filter step by step in the Delphi programming language
You may also check:How to resolve the algorithm Cyclotomic polynomial step by step in the Java programming language
You may also check:How to resolve the algorithm XML/Output step by step in the Erlang programming language
You may also check:How to resolve the algorithm Egyptian division step by step in the Rust programming language