Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
dc4aaac
add PCA to public api
JAi-SATHVIK Jan 6, 2026
27599e1
include pca submodule
JAi-SATHVIK Jan 6, 2026
d77fb0e
Add PCA module with `pca`, `pca_transform`, and `pca_inverse_transfor…
JAi-SATHVIK Jan 6, 2026
24358d1
add PCA unit test
JAi-SATHVIK Jan 6, 2026
1dd44ad
update end interface statement
JAi-SATHVIK Jan 6, 2026
7f79ef6
update CmakeLists
JAi-SATHVIK Jan 6, 2026
0d2738c
fixed_conflicts
JAi-SATHVIK Jan 6, 2026
20b0e98
update interface
JAi-SATHVIK Jan 6, 2026
654edba
allined with the other linalg function
JAi-SATHVIK Jan 7, 2026
b7c2be1
convert to subroutines,updated test
JAi-SATHVIK Jan 7, 2026
63a0a1f
fix errors
JAi-SATHVIK Jan 7, 2026
cfbcdee
fixed errors
JAi-SATHVIK Jan 7, 2026
db19731
fix PCA BLAS/LAPACK linking
JAi-SATHVIK Jan 7, 2026
d9ba548
fix PCA BLAS/LAPACK
JAi-SATHVIK Jan 7, 2026
11902b6
fix: remove xdp/qp from PCA use statements to fix CI builds
JAi-SATHVIK Jan 7, 2026
d7f8790
both updated
JAi-SATHVIK Jan 7, 2026
f8bbd27
test
JAi-SATHVIK Jan 7, 2026
75db887
modify interfaces for core.
JAi-SATHVIK Jan 7, 2026
d72f72c
add stdlib_sorting.fypp in cmakelists.txt
JAi-SATHVIK Jan 8, 2026
44ee2e7
Fix CMakeLists.txt for the addition of stdlib_storting_pca
jvdp1 Jan 8, 2026
6d2a4fd
Merge pull request #1 from jvdp1/fix_jai
JAi-SATHVIK Jan 8, 2026
b3ea627
Add center_data Helper Subroutine
JAi-SATHVIK Jan 13, 2026
0e94be3
Replace Manual Mean with stdlib mean
JAi-SATHVIK Jan 13, 2026
05d4968
Replace Covariance Loops with BLAS syrk
JAi-SATHVIK Jan 13, 2026
d3d1c71
Extract pca_svd_driver and pca_eigh_driver & Updated Main pca Subroutine
JAi-SATHVIK Jan 13, 2026
7b49baa
Merge pull request #2 from JAi-SATHVIK/master-cpy
JAi-SATHVIK Jan 13, 2026
0659b39
optimized for performance and stability
JAi-SATHVIK Jan 13, 2026
ac3b0e9
Merge pull request #3 from JAi-SATHVIK/master-cpy
JAi-SATHVIK Jan 13, 2026
4751866
Merge branch 'master-cpy'
JAi-SATHVIK Jan 13, 2026
cc21db0
Merge branch 'master' of https://github.com/JAi-SATHVIK/stdlib
JAi-SATHVIK Jan 13, 2026
4ac725c
Cache efficency
JAi-SATHVIK Jan 13, 2026
7348faf
fix issues build issues.
JAi-SATHVIK Jan 13, 2026
c58f515
Revert "fix issues build issues."
JAi-SATHVIK Jan 13, 2026
c776e8d
use nested do loops
JAi-SATHVIK Jan 16, 2026
c47e2b6
resolve compiler errors
JAi-SATHVIK Jan 16, 2026
436a526
fix issue
JAi-SATHVIK Jan 17, 2026
143c211
add PCA to public api
JAi-SATHVIK Jan 6, 2026
17cf473
include pca submodule
JAi-SATHVIK Jan 6, 2026
6d0506d
Add PCA module with `pca`, `pca_transform`, and `pca_inverse_transfor…
JAi-SATHVIK Jan 6, 2026
67c7ddf
add PCA unit test
JAi-SATHVIK Jan 6, 2026
720298c
update end interface statement
JAi-SATHVIK Jan 6, 2026
1c2fc75
update CmakeLists
JAi-SATHVIK Jan 6, 2026
c43704c
fixed_conflicts
JAi-SATHVIK Jan 6, 2026
9509dca
update interface
JAi-SATHVIK Jan 6, 2026
36fc211
allined with the other linalg function
JAi-SATHVIK Jan 7, 2026
19f55b6
convert to subroutines,updated test
JAi-SATHVIK Jan 7, 2026
8c4dcd8
fix errors
JAi-SATHVIK Jan 7, 2026
1c97f51
fixed errors
JAi-SATHVIK Jan 7, 2026
2e87b76
fix PCA BLAS/LAPACK linking
JAi-SATHVIK Jan 7, 2026
e665dce
fix PCA BLAS/LAPACK
JAi-SATHVIK Jan 7, 2026
1e6cef7
fix: remove xdp/qp from PCA use statements to fix CI builds
JAi-SATHVIK Jan 7, 2026
f5f0c60
both updated
JAi-SATHVIK Jan 7, 2026
57b3cc5
test
JAi-SATHVIK Jan 7, 2026
f014baf
modify interfaces for core.
JAi-SATHVIK Jan 7, 2026
9dd3212
add stdlib_sorting.fypp in cmakelists.txt
JAi-SATHVIK Jan 8, 2026
202e656
Fix CMakeLists.txt for the addition of stdlib_storting_pca
jvdp1 Jan 8, 2026
c61eb79
Add center_data Helper Subroutine
JAi-SATHVIK Jan 13, 2026
6daccc2
Replace Manual Mean with stdlib mean
JAi-SATHVIK Jan 13, 2026
41a3690
Replace Covariance Loops with BLAS syrk
JAi-SATHVIK Jan 13, 2026
074d34e
Extract pca_svd_driver and pca_eigh_driver & Updated Main pca Subroutine
JAi-SATHVIK Jan 13, 2026
bcabe8f
optimized for performance and stability
JAi-SATHVIK Jan 13, 2026
a769f25
Cache efficency
JAi-SATHVIK Jan 13, 2026
587abf7
fix issues build issues.
JAi-SATHVIK Jan 13, 2026
83fe1d0
Revert "fix issues build issues."
JAi-SATHVIK Jan 13, 2026
5d0c88e
use nested do loops
JAi-SATHVIK Jan 16, 2026
9979449
resolve compiler errors
JAi-SATHVIK Jan 16, 2026
b23a670
fix issue
JAi-SATHVIK Jan 17, 2026
6dd0b39
Merge branch 'master' of https://github.com/JAi-SATHVIK/stdlib
JAi-SATHVIK Jan 17, 2026
ecbccd1
remove unused BLAS constants to prevent compiler warnings
JAi-SATHVIK Jan 17, 2026
cc10e95
remove unused import
JAi-SATHVIK Jan 17, 2026
496d744
remove unused output arrays
JAi-SATHVIK Jan 17, 2026
6c48366
remove unused output arrays
JAi-SATHVIK Jan 17, 2026
f1d5182
Merge branch 'master' of https://github.com/JAi-SATHVIK/stdlib
JAi-SATHVIK Jan 17, 2026
a837b6b
fix: replace string concatenation with comma args to fix ifx crash
JAi-SATHVIK Jan 19, 2026
baf8ff5
Use REAL_KINDS_TYPES
JAi-SATHVIK Jan 20, 2026
f931908
Change singular_values
JAi-SATHVIK Jan 20, 2026
53bb939
Remove scale_factor variable
JAi-SATHVIK Jan 20, 2026
3c98dee
fix issues
JAi-SATHVIK Jan 20, 2026
cb9a5ea
refactor
JAi-SATHVIK Jan 23, 2026
8c83389
Merge https://github.com/fortran-lang/stdlib
JAi-SATHVIK Jan 23, 2026
3b9b085
remove sort index,lower triangle fill.
JAi-SATHVIK Jan 23, 2026
25e4eab
Fix eigh: use upper_a instead of lower
JAi-SATHVIK Jan 24, 2026
9604ccb
update center data subroutine
JAi-SATHVIK Jan 24, 2026
a66aee6
remove elsewhere clause
JAi-SATHVIK Jan 24, 2026
25bf66f
Merge branch 'master' of https://github.com/JAi-SATHVIK/stdlib
JAi-SATHVIK Jan 24, 2026
641243f
update specs
JAi-SATHVIK Jan 26, 2026
ef2f624
fix
JAi-SATHVIK Jan 27, 2026
33c0270
,
JAi-SATHVIK Jan 30, 2026
23257e9
update test file
JAi-SATHVIK Feb 6, 2026
cb908bf
loop fix
JAi-SATHVIK Feb 6, 2026
e2885ae
update documentation
JAi-SATHVIK Feb 21, 2026
775ccc3
add checks
JAi-SATHVIK Feb 21, 2026
1ac24a0
add test
JAi-SATHVIK Feb 21, 2026
3b179e8
add keyword-based transform
JAi-SATHVIK Feb 21, 2026
4d2d7a1
fix interface declarations
JAi-SATHVIK Mar 12, 2026
f4c8245
reorder arguments
JAi-SATHVIK Mar 12, 2026
b267c33
update docs and tests
JAi-SATHVIK Mar 12, 2026
8d4cd08
Resolve merge conflict in test/stats/CMakeLists.txt and sync local ma…
JAi-SATHVIK Mar 12, 2026
fd611a7
Add explicit shape validation and nc < 1 checks to PCA subroutines
JAi-SATHVIK Mar 15, 2026
16f151f
Merge branch 'fortran-lang:master' into master
JAi-SATHVIK Mar 18, 2026
87a1783
Initialize regex module with minimal boilerplate
JAi-SATHVIK Mar 31, 2026
b11779b
resolve parsing and bounding checking
JAi-SATHVIK Apr 1, 2026
48e2526
remove use statement, add_subdir
JAi-SATHVIK Apr 1, 2026
629e5bb
rewrote testdrive
JAi-SATHVIK Apr 3, 2026
c0df858
Merge branch 'fortran-lang:master' into master
JAi-SATHVIK Apr 3, 2026
4d991c0
fix off-by-one match_start position
JAi-SATHVIK Apr 3, 2026
8e2390f
update doc
JAi-SATHVIK Apr 4, 2026
7b00548
Merge branch 'master' of https://github.com/JAi-SATHVIK/stdlib into r…
JAi-SATHVIK Apr 4, 2026
bab5e5e
core engine logic, purity fix
JAi-SATHVIK Apr 5, 2026
c58b15d
standalone example (pattern matching)
JAi-SATHVIK Apr 5, 2026
8d27abc
new build config
JAi-SATHVIK Apr 5, 2026
8ed7942
add regex examples
JAi-SATHVIK Apr 5, 2026
29f598b
update docs
JAi-SATHVIK Apr 5, 2026
731b57c
Merge branch 'master' of https://github.com/fortran-lang/stdlib into …
JAi-SATHVIK Apr 10, 2026
dbeedce
add strict rules
JAi-SATHVIK Apr 10, 2026
8319cc3
Merge branch 'fortran-lang:master' into regex
JAi-SATHVIK Apr 14, 2026
0cc9abd
refactor utility function
JAi-SATHVIK Apr 17, 2026
544f34a
address review feedback on unit numbers and constants
JAi-SATHVIK Apr 19, 2026
d78f89a
regex: add CMake dependency for stdlib_core
JAi-SATHVIK Apr 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ check_modular("SPECIALMATRICES")
check_modular("STRINGLIST")
check_modular("STATS")
check_modular("SYSTEM")
check_modular("REGEX")

option(FIND_BLAS "Find external BLAS and LAPACK" ON)

Expand Down
1 change: 1 addition & 0 deletions doc/specs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This is an index/directory of the specifications (specs) for each new module/fea
- [optval](./stdlib_optval.html) - Fallback value for optional arguments
- [quadrature](./stdlib_quadrature.html) - Numerical integration
- [random](./stdlib_random.html) - Probability Distributions random number generator
- [regex](./stdlib_regex.html) - Regular expression pattern matching
- [sorting](./stdlib_sorting.html) - Sorting of rank one arrays
- [stats](./stdlib_stats.html) - Descriptive Statistics
- [stats_distributions_uniform](./stdlib_stats_distribution_uniform.html) - Uniform Probability Distribution
Expand Down
138 changes: 138 additions & 0 deletions doc/specs/stdlib_regex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: regex
---

# Regular Expressions

[TOC]

## Overview

The `stdlib_regex` module provides a pure Fortran regular expression engine
based on Thompson's NFA (Nondeterministic Finite Automaton) construction.
It guarantees linear-time matching `O(n × m)` with no backtracking,
making it safe for use with arbitrary input without risk of catastrophic
performance degradation.

### Supported Syntax

| Pattern | Description | Example |
|-------------|--------------------------------------|------------------|
| `.` | Match any single character | `a.c` → `abc` |
| `*` | Zero or more of preceding element | `ab*c` → `ac` |
| `+` | One or more of preceding element | `ab+c` → `abbc` |
| `?` | Zero or one of preceding element | `colou?r` |
| `\|` | Alternation | `cat\|dog` |
| `(` `)` | Grouping | `(ab)+` |
| `[...]` | Character class | `[a-z]` |
| `[^...]` | Negated character class | `[^0-9]` |
| `^` | Start of string anchor | `^foo` |
| `$` | End of string anchor | `bar$` |
| `\d` | Digit `[0-9]` | `\d+` |
| `\w` | Word character `[a-zA-Z0-9_]` | `\w+` |
| `\s` | Whitespace (space, tab, newline, CR) | `\s+` |
| `\` | Escape next character | `\.` |

## `regex_type` - Regular expression type

### Status

Experimental

### Description

A derived type representing a compiled regular expression. It stores the
internal NFA state graph produced by `regcomp` and is passed to `regmatch`
for pattern matching.

### Syntax

```fortran
type(regex_type) :: re
```

## `regcomp` - Compile a regular expression

### Status

Experimental

### Description

Compiles a regular expression pattern string into a `regex_type` object.
The compiled object can then be reused for multiple calls to `regmatch`
without recompilation.

### Syntax

```fortran
call [[stdlib_regex(module):regcomp(subroutine)]](re, pattern [, status])
```

### Class

Subroutine

### Arguments

`re`: Shall be of type `regex_type`. It is an `intent(out)` argument.
The compiled regular expression.

`pattern`: Shall be of type `character(len=*)`. It is an `intent(in)` argument.
The regular expression pattern string to compile.

`status` (optional): Shall be of type `integer`. It is an `intent(out)` argument.
Returns 0 on success, or a non-zero value if the pattern is invalid
(e.g., mismatched parentheses or brackets).

### Example

```fortran
{!example/regex/example_regex_regcomp.f90!}
```
Comment thread
jalvesz marked this conversation as resolved.

## `regmatch` - Match a compiled regular expression

### Status

Experimental

### Description

Searches for the first occurrence of the compiled regular expression `re`
within the input `string`. If a match is found, `is_match` is set to `.true.`
and the optional `match_start` and `match_end` arguments are set to
the 1-based start and end positions of the matched substring.

### Syntax

```fortran
call [[stdlib_regex(module):regmatch(subroutine)]](re, string, is_match [, match_start, match_end])
```

### Class

Subroutine

### Arguments

`re`: Shall be of type `regex_type`. It is an `intent(in)` argument.
A compiled regular expression obtained from `regcomp`.

`string`: Shall be of type `character(len=*)`. It is an `intent(in)` argument.
The input string to search for a match.

`is_match`: Shall be of type `logical`. It is an `intent(out)` argument.
Set to `.true.` if a match is found, `.false.` otherwise.

`match_start` (optional): Shall be of type `integer`. It is an `intent(out)` argument.
The 1-based index of the first character of the match.

`match_end` (optional): Shall be of type `integer`. It is an `intent(out)` argument.
The 1-based index of the last character of the match.

### Example

```fortran
Comment thread
jalvesz marked this conversation as resolved.
{!example/regex/example_regex_regmatch.f90!}
```
3 changes: 3 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ add_subdirectory(optval)
if (STDLIB_QUADRATURE)
add_subdirectory(quadrature)
endif()
if (STDLIB_REGEX)
add_subdirectory(regex)
endif()
add_subdirectory(selection)
add_subdirectory(sorting)
add_subdirectory(specialfunctions_gamma)
Expand Down
2 changes: 2 additions & 0 deletions example/regex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ADD_EXAMPLE(regex_regcomp)
ADD_EXAMPLE(regex_regmatch)
10 changes: 10 additions & 0 deletions example/regex/example_regex_regcomp.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
program example_regex_regcomp
use stdlib_regex, only: regex_type, regcomp
implicit none
type(regex_type) :: re
integer :: stat

call regcomp(re, "(cat|dog)s?", stat)
if (stat /= 0) error stop "Invalid regex pattern"
print *, "Pattern compiled successfully."
end program example_regex_regcomp
25 changes: 25 additions & 0 deletions example/regex/example_regex_regmatch.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
program example_regex_regmatch
use stdlib_regex, only: regex_type, regcomp, regmatch
implicit none
type(regex_type) :: re
logical :: found
integer :: stat, ms, me

! Find a sequence of digits
call regcomp(re, "[0-9]+", stat)
call regmatch(re, "foo123bar", found, ms, me)
print "(a,l1,a,i0,a,i0)", "found = ", found, ", ms = ", ms, ", me = ", me

! Anchored match
call regcomp(re, "^hello", stat)
call regmatch(re, "hello world", found)
print "(a,l1)", "found = ", found
call regmatch(re, "say hello", found)
print "(a,l1)", "found = ", found

! Alternation with optional suffix
call regcomp(re, "(cat|dog)s?", stat)
call regmatch(re, "I like cats", found, ms, me)
print "(a,l1,a,i0,a,i0)", "found = ", found, ", ms = ", ms, ", me = ", me

end program example_regex_regmatch
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ add_subdirectory(datetime)
ADD_SUBDIR(system)

ADD_SUBDIR(stats)
ADD_SUBDIR(regex)

add_subdirectory(sparse)

Expand Down
12 changes: 12 additions & 0 deletions src/regex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(regex_fppFiles
)

set(regex_cppFiles
)

set(regex_f90Files
stdlib_regex.f90
)

configure_stdlib_target(${PROJECT_NAME}_regex regex_f90Files regex_fppFiles regex_cppFiles)
target_link_libraries(${PROJECT_NAME}_regex PUBLIC ${PROJECT_NAME}_core)
Loading
Loading