[PYTHON] [Numpy, scipy] How to calculate the square root of a semi-fixed definite matrix

import numpy as np
import scipy.linalg as LA

def sqrtmh(A):
    vals, vecs = LA.eigh(A)
    return vecs @ np.diag(np.sqrt(vals)) @ vecs.T.conjugate()

reference

-[Square root of a matrix](https://ja.wikipedia.org/wiki/%E8%A1%8C%E5%88%97%E3%81%AE%E5%B9%B3%E6%96%B9% E6% A0% B9) -[Positive Definite Matrix](https://ja.wikipedia.org/wiki/%E8%A1%8C%E5%88%97%E3%81%AE%E5%AE%9A%E5%80%A4 % E6% 80% A7)

Recommended Posts

[Numpy, scipy] How to calculate the square root of a semi-fixed definite matrix
How to calculate the volatility of a brand
Steps to calculate the likelihood of a normal distribution
[Ubuntu] How to delete the entire contents of a directory
Calculate the square root of 2 in millions of digits with python
How to calculate the amount of calculation learned from ABC134-D
How to find the scaling factor of a biorthogonal wavelet
How to connect the contents of a list into a string
How to calculate the autocorrelation coefficient
How to determine the existence of a selenium element in Python
How to check the memory size of a variable in Python
How to check the memory size of a dictionary in Python
How to find the memory address of a Pandas dataframe value
How to output the output result of the Linux man command to a file
How to get the vertex coordinates of a feature in ArcPy
[Python] How to make a matrix of repeating patterns (repmat / tile)
[NNabla] How to remove the middle tier of a pre-built network
How to check the version of Django
How to calculate Use% of df command
[Introduction to Python] How to sort the contents of a list efficiently with list sort
How to put a line number at the beginning of a CSV file
How to create a wrapper that preserves the signature of the function to wrap
How to play a video while watching the number of frames (Mac)
How to sort by specifying a column in the Python Numpy array.
How to pass the execution result of a shell command in a list in Python
How to mention a user group in slack notification, how to check the id of the user group
[NNabla] How to get the output (variable) of the middle layer of a pre-built network
How to count the number of elements in Django and output to a template
How to access the contents of a Linux disk on a Mac (but read-only)
[python] How to sort by the Nth Mth element of a multidimensional array
A memorandum of how to execute the! Sudo magic command in Jupyter Notebook
How to make a Raspberry Pi that speaks the tweets of the specified user
How to get a list of files in the same directory with python
[Introduction to Python] How to get the index of data with a for statement
A simple example of how to use ArgumentParser
How to find the area of the Voronoi diagram
Calculate the probability of outliers on a boxplot
How to display the modification date of a file in C language up to nanoseconds
[Python] How to calculate the approximation formula of the same intercept 0 as Excel [scikit-learn] Memo
How to identify the element with the smallest number of characters in a Python list?
How to confirm the Persival theorem using the Fourier transform (FFT) of matplotlib and scipy
[Ruby] How to replace only a part of the string matched by the regular expression?
How to check in Python if one of the elements of a list is in another list
The world's most easy-to-understand explanation of how to make a LINE BOT (1) [Account preparation]
[NNabla] How to add a new layer between the middle layers of a pre-built network
A memo on how to overcome the difficult problem of capturing FX with AI
How to change the generated image of GAN to a high quality one to your liking
Read the Python-Markdown source: How to create a parser
How to know the port number of the xinetd service
Calculate volume from the two-dimensional structure of a compound
How to write a GUI using the maya command
How to get the number of digits in Python
How to create a submenu with the [Blender] plugin
Try to solve the problems / problems of "Matrix Programmer" (Chapter 1)
How to visualize the decision tree model of scikit-learn
How to write a list / dictionary type of Python3
[Blender] How to dynamically set the selection of EnumProperty
Basics of PyTorch (2) -How to make a neural network-
[Python] Summary of how to specify the color of the figure
How to hit the document of Magic Function (Line Magic)
How to access the global variable of the imported module