{"id":18854383,"url":"https://github.com/urbanjost/m_sets","last_synced_at":"2025-09-01T20:39:53.918Z","repository":{"id":182907369,"uuid":"669302516","full_name":"urbanjost/M_sets","owner":"urbanjost","description":"basic set functions","archived":false,"fork":false,"pushed_at":"2024-10-08T23:02:59.000Z","size":778,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-08T03:47:58.607Z","etag":null,"topics":["fortran","fortran-package-manager","matlab","sets"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbanjost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-07-21T21:33:46.000Z","updated_at":"2024-10-14T15:08:23.000Z","dependencies_parsed_at":"2024-03-31T14:31:37.716Z","dependency_job_id":null,"html_url":"https://github.com/urbanjost/M_sets","commit_stats":null,"previous_names":["urbanjost/m_sets"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_sets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_sets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_sets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_sets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbanjost","download_url":"https://codeload.github.com/urbanjost/M_sets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231897531,"owners_count":18442648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fortran","fortran-package-manager","matlab","sets"],"created_at":"2024-11-08T03:48:04.220Z","updated_at":"2025-09-01T20:39:53.903Z","avatar_url":"https://github.com/urbanjost.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](docs/images/venn_little.gif)](https://urbanjost.github.io/M_sets/fpm-ford/index.html)\n# [M_sets](https://urbanjost.github.io/M_sets/man3.html)\n\n## Name\n   **M_sets**(3f) - functions reminiscent of Matlab set functions\n\n## Description\n\nSet-theory operations compare the elements in two sets to find\ncommonalities, differences, and membership.\n\nM_set(3f) is a Fortran module comprising a small group of set-theory\nfunctions reminiscent of related Matlab procedures.\n\nM_set(3f) is intended to be built with and used by fpm(1) projects.\nIt requires M_orderpack(3f) as a dependency, which is of course\ntaken care of automatically via fpm(1).\n\nCurrently the allowed sets are vectors of integer numbers or arrays\nof character variables. real numbers are allowed but \"caveat emptor\",\nas comparing floats for equality has issues. You may have to condition\nthe float data by converting it to scaled integers or using intrinsics\nsuch as NEAREST(3f) to produce the desired results.\n\n\u003c!--\nM_sets(3f) basically uses some simple calls to the M_orderpack(3f)\nmodule that make loose use of memory allocation and space, but are\nadequate for the vast majority of cases.\n\n -- unions, intersection, and set membership.\n--\u003e\n\n## Functions\n + union(A,B,setOrder)     - Join two sets and remove duplicates of values\n + unique(A,setOrder)      - Remove duplicates of values from a set\n + intersect(A,B,setOrder) - Find the values common to both A and B\n + setdiff(A,B,setOrder)   - Find the values in A that are not in B\n + ismember(A,B,setOrder)  - Create a mask of A marking elements also in B\n + setxor(A,B,setOrder)    - Find values of A and B not in both arrays\n + issorted(A)             - Determine if array is already sorted\n + bool(expr)              - returns 1 if expression is TRUE, else returns 0.\n\n The subsequent data may be produced sorted, or left in the order\n encountered.\n\n They (currently) select elements and do not return index locations. Since\n they already internally heavily depend on a multiplicity subroutine\n that might be unexpectedly easy to add, though.\n\n## Example\n\n```fortran\n   program demo_M_sets\n   use M_sets, only: \u0026\n   \u0026 unique, intersect, union, setdiff, ismember, setxor, issorted, bool\n   character(len=*),parameter :: all='(*(g0,1x))'\n   character(len=*),parameter :: nl=new_line('A')\n   integer, allocatable      :: A(:)\n   integer, allocatable      :: B(:)\n   integer, allocatable      :: C(:)\n\n      A = [10, -10, 0, 1, 2, 3, 3, 2, 1, -10]\n      !\n      print all                                                   ,nl, \u0026\n      'UNIQUE','Find the unique elements of vector A.'            ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'sorted=',unique(A)                                         ,nl, \u0026\n      'stable=',unique(A, setOrder='stable')\n\n      A=[5, 7, 1]\n      B=[3, 1, 1]\n      !\n      print all                                                   ,nl, \u0026\n      'UNION', 'Find the union of vectors A and B.'               ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'B=', B                                                     ,nl, \u0026\n      'sorted=',union(A, B, 'sorted')                             ,nl, \u0026\n      'stable=',union(A, B, 'stable')\n\n      A=[7, 1, 7, 7, 4]\n      B=[7, 0, 4, 4, 0]\n      !\n      print all                                                   ,nl, \u0026\n      'INTERSECT', 'Find the values common to both A and B.'      ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'B=', B                                                     ,nl, \u0026\n      'sorted=',intersect(A, B)                                   ,nl, \u0026\n      'stable=',intersect(A, B, setOrder='stable')\n\n      A=[3, 6, 2, 1, 5, 1, 1]\n      B=[2, 4, 6]\n      !\n      print all                                                   ,nl, \u0026\n      'SETDIFF','Find the values in A that are not in B.'         ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'B=', B                                                     ,nl, \u0026\n      'sorted=',setdiff(A, B, 'sorted')                           ,nl, \u0026\n      'stable=',setdiff(A, B, 'stable')\n\n      A=[5,3,4,2]\n      B=[2,4,4,4,6,8]\n      !\n      print all                                                   ,nl, \u0026\n      'ISMEMBER','Determine which elements of A are also in B.'   ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'B=', B                                                     ,nl, \u0026\n      'in A and B=',ismember(A,B)\n\n      A=[5,1,3,3,3]\n      B=[4,1,2]\n      !\n      print all                                                   ,nl, \u0026\n      'SETXOR'                                                       , \u0026\n      'Find values of A and B not in their intersection.'         ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'B=', B                                                     ,nl, \u0026\n      'sorted=',setxor(A,B)                                       ,nl, \u0026\n      'stable=',setxor(A,B,'stable')\n\n      A=[1,2,3,4,5]\n      B=[5,4,3,2,1]\n      !\n      print all                                                   ,nl, \u0026\n      'ISSSORTED'                                                    , \u0026\n      'confirm whether array is sorted in ascending order or not' ,nl, \u0026\n      'A=', A                                                     ,nl, \u0026\n      'B=', B                                                     ,nl, \u0026\n      'is A sorted?',issorted(A)                                  ,nl, \u0026\n      'is B sorted?',issorted(B)\n\n   end program demo_M_sets\n```\n\u003c!--\n123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789\n--\u003e\n\nResults:\n```text\n \u003e\n \u003e  UNIQUE Find the unique elements of vector A.\n \u003e  A= 10 -10 0 1 2 3 3 2 1 -10\n \u003e  sorted= -10 0 1 2 3 10\n \u003e  stable= 10 -10 0 1 2 3\n \u003e\n \u003e  UNION Find the union of vectors A and B.\n \u003e  A= 5 7 1\n \u003e  B= 3 1 1\n \u003e  sorted= 1 3 5 7\n \u003e  stable= 5 7 1 3\n \u003e\n \u003e  INTERSECT Find the values common to both A and B.\n \u003e  A= 7 1 7 7 4\n \u003e  B= 7 0 4 4 0\n \u003e  sorted= 4 7\n \u003e  stable= 7 4\n \u003e\n \u003e  SETDIFF Find the values in A that are not in B.\n \u003e  A= 3 6 2 1 5 1 1\n \u003e  B= 2 4 6\n \u003e  sorted= 1 3 5\n \u003e  stable= 3 1 5\n \u003e\n \u003e  ISMEMBER Determine which elements of A are also in B.\n \u003e  A= 5 3 4 2\n \u003e  B= 2 4 4 4 6 8\n \u003e  in A and B= 0 0 1 1\n \u003e\n \u003e  SETXOR Find values of A and B not in their intersection.\n \u003e  A= 5 1 3 3 3\n \u003e  B= 4 1 2\n \u003e  sorted= 2 3 4 5\n \u003e  stable= 5 3 4 2\n \u003e\n \u003e  ISSSORTED confirm whether array is sorted in ascending order or not\n \u003e  A= 1 2 3 4 5\n \u003e  B= 5 4 3 2 1\n \u003e  is A sorted? 1\n \u003e  is B sorted? 0\n```\n\u003c!--\n## Building the module using make![gmake](docs/images/gnu.gif)\n\nThis will compile the Fortran module and basic example programs that exercise the routines:\n\n```bash\n     git clone https://github.com/urbanjost/M_sets.git\n\n     cd M_sets/src\n     # change Makefile if not using one of the listed compilers\n\n     # for gfortran\n     make clean\n     make gfortran\n\n     # for ifort\n     make clean\n     make ifort\n\n     # for nvfortran\n     make clean\n     make nvfortran\n```\n   Note that to specifically get release 2.0.0 you would use\n```bash\n     git clone --branch 2.0.0 https://github.com/urbanjost/M_sets.git\n```\n--\u003e\n\n---\n## Build and test with ![fpm](docs/images/fpm_logo.gif)\n\n   Download the github repository and build it with fpm ( as described at\n   [Fortran Package Manager](https://github.com/fortran-lang/fpm) )\n```bash\n        git clone https://github.com/urbanjost/M_sets.git\n        cd M_sets\n        fpm build\n```\n\n   or just list it as a dependency in your fpm.toml project file.\n\n```toml\n        [dependencies]\n        M_sets        = { git = \"https://github.com/urbanjost/M_sets.git\" }\n```\n---\n## Documentation ![docs](docs/images/docs.gif)\n\nThe documentation for each procedure is included in the source.\nThat documentation is also available as a flat text file, HTML\ndocuments, and man-pages.\n\n### User\n   - A [text manual](https://urbanjost.github.io/M_sets/manual.txt)\n     contains all the procedure descriptions in a single flat ASCII\n     text file.\n\n   - [routines](https://urbanjost.github.io/M_sets/man3.html)\n     are also described in HTML form using the format of man-pages.\n\u003c!--\n     and [programs](https://urbanjost.github.io/M_sets/man1.html)\n--\u003e\n   - For easier searching and printing Javascript is used to combine\n     all those HTML descriptions of the man-pages into a single\n     [book](https://urbanjost.github.io/M_sets/BOOK_M_sets.html).\n\n   - ![man-pages](docs/images/manpages.gif) are the de-facto standard\n     method of providing procedure descriptions on Unix, GNU/Linux,\n     OpenBSD, Cygwin, WLS, and other ULS (Unix-Like Systems)\n\n     Installation can vary depending on whether you are installing\n     personal copies or as an administrator, but man-pages are well suited\n     for any CLI user (Command-Line Interface):\n\n      + [manpages.zip](https://urbanjost.github.io/M_sets/manpages.zip)\n      + [manpages.tgz](https://urbanjost.github.io/M_sets/manpages.tgz)\n\n   - [CHANGELOG](docs/CHANGELOG.md) provides a history of significant changes\n---\n### Developer\n   - [ford(1) output](https://urbanjost.github.io/M_sets/fpm-ford/index.html).\n   - [doxygen(1) output](https://urbanjost.github.io/M_sets/doxygen_out/html/index.html).\n   - [github action status](docs/STATUS.md)\n---\n\n## References ![-](docs/images/ref.gif)\n\n## See also ![-](docs/images/demos.gif)\n   * [M_orderpack](https://github.com/urbanjost/M_orderpack)\n   * [M_random](https://github.com/urbanjost/M_random)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_sets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbanjost%2Fm_sets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_sets/lists"}