README.md

July 27, 2024 ยท View on GitHub

CI


utf8f

Fortran tri_indices functions

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact

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.

(back to top)

Getting Started

Prerequisites

  • gcc >= 9.4.0
  • gfortran >= 9.4.0
  • cmake >= 3.9

Installation

  1. Clone the repo
    git clone https://github.com/yymmt742/tri_indices
    
  2. Build fortran library
    mkdir build && cd build
    cmake ..
    make install
    

(back to top)

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.

SubroutineArguments (intent(in))Arguments (intent(out))Description
pack_tri_indices(i,j,[d],k)i, j, d(optional)kMaps 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, jMaps the index k of the packed 1-dimensional array to the indices i,j of upper trianglar matrix.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

YYMMT742 - yymmt@kuchem.kyoto-u.ac.jp

(back to top)