Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A alexandria
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • alexandria
  • alexandria
  • Merge requests
  • !20

Merged
Created May 11, 2020 by Anish Moorthy@anlshDeveloper

Add functions relating to multidimensional array indexing conversions

  • Overview 1
  • Commits 2
  • Changes 4

Similar functions are provided in CL, but they operate on arrays when all they really need are the dimensions. This sometimes proves an annoyance, and I thought I'd submit the more general functions here. The behavior should exactly mimic that of the CL counterparts, except that the error which array-in-bounds-p signals is implementation-dependent and dim-in-bounds-p always signals a SIMPLE-ERROR.

This PR implements associated tests as well.

EDIT: I have also implemented a function to convert a row-major index to axis indices based on a given set of dimensions, and have implemented a test for that as well


I wanted to further propose extending these functions to cases when fewer indices than the rank of the array are given, ie something like

(defvar a #2A((a b c) (d e f))
(row-major-index (array-dimensions a) 0 0)     ;; 0
(row-major-index (array-dimensions a) 0)       ;; 0 . Currently an error
(row-major-index (array-dimensions a) 1)       ;; 3 . Also currently an error

(dim-in-bounds-p '(4 3 2 1) 0)                 ;; t . Currently an error

This behavior (unimplemented, to be clear) diverges more from the spec, but I often find it useful when working with multi-dimensional arrays. I can update the PR if we decide to support it.

Edited May 12, 2020 by Anish Moorthy
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: indexing-helpers