ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_arrayStrip Module Reference

This module contains procedures and generic interfaces for stripping a given pattern from the left and right ends of an array of arbitrary intrinsic type and kind.
More...

Data Types

interface  getSIL
 Generate and return index, the index of the first element of the input array such that array(1:index-1) contains only full repetitions of the user-specified pattern. More...
 
interface  getSIR
 Generate and return index, the index of the last element of the input array such that array(index+1:) contains only full repetitions of the user-specified pattern. More...
 
interface  getStripped
 Generate and return the input array modified such that all instances of the input pattern are stripped from its both sides or only the side specified. More...
 

Variables

character(*, SK), parameter MODULE_NAME = "@pm_arrayStrip"
 

Detailed Description

This module contains procedures and generic interfaces for stripping a given pattern from the left and right ends of an array of arbitrary intrinsic type and kind.

The functionalities of the getStripped generic interface of this module are similar to the strip() method of Python strings.
However, keep in mind that returning an allocatable stripped copy of the input can be an expensive operation.
If performance matters, use instead the generic interfaces getSIL for left-stripping getSIR for right-stripping.
These indexing avoid the unnecessary and costly allocations, potentially leading to much faster runtime performance.

Developer Remark:
The subroutine equivalents of the function interface getStripped of this module were deemed unnecessary.
The functional interfaces exist solely for improved flexibility.
If performance matters, getSIL and getSIR can be readily used to eliminate the avoidable allocations within the procedures.
See also
pm_arraySplit
pm_arrayRemove
Test:
test_pm_arrayStrip
Todo:
Low Priority: A benchmark comparing the performance of indexing vs. allocating a modified array should be provided here.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, 3:48 AM, October 13, 2017, Institute for Computational Engineering and Sciences, Austin, TX

Variable Documentation

◆ MODULE_NAME

character(*,SK), parameter pm_arrayStrip::MODULE_NAME = "@pm_arrayStrip"

Definition at line 64 of file pm_arrayStrip.F90.