Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

genarray #1

Open
cher-nov opened this issue Mar 20, 2017 · 1 comment
Open

genarray #1

cher-nov opened this issue Mar 20, 2017 · 1 comment
Assignees

Comments

@cher-nov
Copy link
Owner

cher-nov commented Mar 20, 2017

Notes:

  • Add "count of dimensions" field into header.
  • Use stdarg.h to read arguments for such functions.
  • Each next dimension has the number of dimensions less by 1 than previous.
  • Recursion everywhere, or use an implementation of queue.
  • Functions must be placed in a separate header & module.
  • To instantiate both single- and multi-dimensional functions for one vector type, typesets should be used.
@cher-nov cher-nov changed the title Function to create multidimensional vectors by one call. Functions to manage multidimensional vectors. Mar 20, 2017
@cher-nov cher-nov self-assigned this Mar 20, 2017
@cher-nov cher-nov changed the title Functions to manage multidimensional vectors. Functions to manage multidimensional vectors Mar 30, 2017
@cher-nov
Copy link
Owner Author

cher-nov commented Dec 22, 2021

I've came up with an idea that the current implemenation of vector could be somewhat easily extended with support for multidimensional vectors by storing jump pointers to dimensions between the header and the actual storage. It may seem ineffective by memory, but actually it's just like storing vectors-of-vectors because subvectors need capacity for their headers as well.

So we need a new genarray type, because vector-of-vectors is not the same as matrix (since subvectors can have different lengths). As opposed to this, genarray will be pre-shaped. It means that its dimensions will be static, and to add new data row or column to it, you will have to reshape it first.

So the idea is to have something like that:

  1. Memory structure:
[header][1st dimension jump pointers][2nd d.j.ps.]...[Nth d.j.ps.][storage]

Note that "0th dimension" have no jump pointers, as one-dimensioned array doesn't need them at all.

  1. User type of a container will be T***..., where number of asterisks is a number of dimensions.

  2. User specifies shapes using varargs:

garr_reshape( some_array, 3 /* number of new dimensions */, ... /* sizes of every dimension */ );

@cher-nov cher-nov changed the title Functions to manage multidimensional vectors genarray Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant