README.md
July 27, 2024 ยท View on GitHub
utf8f
Fortran tri_indices functions
Table of Contents
About The Project
tri_indices provides a mapping/inverse mapping from an index of an upper triangular matrix to an index of a one-dimensional array.
Getting Started
Prerequisites
- gcc >= 9.4.0
- gfortran >= 9.4.0
- cmake >= 3.9
Installation
- Clone the repo
git clone https://github.com/yymmt742/tri_indices - Build fortran library
mkdir build && cd build cmake .. make install
Usage
program main
use mod_tri_indices
implicit none
integer :: i, j, k
do j=1,10
do i=1, j
call pack_tri_indices(i, j, k) ! k = 1 ... 55
end do
end do
do k=1,55
call unpack_tri_indices(k=k, i, j) ! i and j are upper tri indeces
end do
do j=2,10
do i=1, j - 1
call pack_tri_indices(i, j, d=1, k) ! k = 1 ... 45
end do
end do
do k=1,45
call unpack_tri_indices(k=k, d=1, i, j) ! i and j are upper tri indeces without diagonal elements
end do
end program main
The following functions are available.
| Subroutine | Arguments (intent(in)) | Arguments (intent(out)) | Description |
|---|---|---|---|
| pack_tri_indices(i,j,[d],k) | i, j, d(optional) | k | Maps the indices i,j of upper trianglar matrix to the index k of the packed 1-dimensional array. |
| unpack_tri_indices(k, [d], i, j) | k, d(optional) | i, j | Maps the index k of the packed 1-dimensional array to the indices i,j of upper trianglar matrix. |
License
Distributed under the MIT License. See LICENSE for more information.
Contact
YYMMT742 - yymmt@kuchem.kyoto-u.ac.jp