/usr/share/psi/samples/matrix1/input.dat is in psi4-data 1:0.3-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #! An example of using BLAS and LAPACK calls directly from the Psi input file, demonstrating
#! matrix multiplication, eigendecomposition, Cholesky decomposition and LU decomposition.
#! These operations are performed on vectors and matrices provided from the Psi library.
memory 250 mb
# Example of matrix multiplication
print_out('\n ==> Matrix Multiplication <== \n\n')
n = 3
A = psi4.Matrix(n, n)
B = psi4.Matrix(n, n)
C = psi4.Matrix(n, n)
A.set_name('A')
B.set_name('B')
C.set_name('C')
# The matrix set method takes 4 arguments: irrep, row, col, value
# Values are initialized to 0 by default
B.set(0, 0, 1, 1.0)
B.set(0, 1, 0, 2.0)
B.set(0, 2, 0, 3.0)
A.set(0, 0, 0, 2.0)
A.set(0, 1, 1, 2.0)
A.set(0, 2, 2, 2.0)
A.print_out()
B.print_out()
psi4.DGEMM(0, 'N', 'N', n, n, n, 1.0, A, n, B, n, 0.0, C, n)
C.print_out()
print_out('\n ==> Eigendecomposition (Hilbert Matrix) <== \n\n')
n = 4;
A = psi4.Matrix(n,n)
for i in range(1,n+1):
for j in range(1,n+1):
A.set(0, i-1, j-1, 1.0/(i + j - 1))
A.set_name('Hilbert Matrix')
A.print_out();
# Allocate a work array and some storage for the eigenvalues
W = psi4.Vector(4*n);
D = psi4.Vector(n);
# On input, A is the matrix and on output it contains the eigenvectors
info = psi4.DSYEV(0, 'V','U', n, A, n, D, W, 4*n)
A.set_name("Eigenvectors")
# Make first element of eigenvector positive if desired
for i in range(1,n):
if A.get(i,0) < 0 :
A.scale_row(0, i, -1)
print_out(' Eigenvalues')
D.print_out()
A.print_out()
print_out('\n ==> Cholesky Decomposition (Hilbert Matrix) <== \n\n')
n = 4;
A = psi4.Matrix(n,n)
for i in range(1,n+1):
for j in range(1,n+1):
A.set(0, i-1, j-1, 1.0/(i + j - 1))
A.set_name('Hilbert Matrix')
A.print_out();
info = psi4.DPOTRF(0, 'U', n, A, n)
for i in range(0,n):
for j in range(i+1,n):
A.set(0, i, j, 0.0)
A.set_name('Hilbert Matrix Cholesky Decomposition (T)')
A.print_out()
print_out('\n ==> LU Decomposition (Hilbert Matrix) <== \n\n')
n = 4;
A = psi4.Matrix(n,n)
piv = psi4.IntVector(n)
for i in range(1,n+1):
for j in range(1,n+1):
A.set(0, i-1, j-1, 1.0/(i + j - 1))
A.set_name('Hilbert Matrix')
A.print_out();
info = psi4.DGETRF(0, n, n, A, n, piv)
A.set_name('Hilbert Matrix LU Decomposition (T)')
A.print_out()
|