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

can one access the TypedArray buffer after .pick or .slice? #145

Open
fangq opened this issue Feb 3, 2024 · 0 comments
Open

can one access the TypedArray buffer after .pick or .slice? #145

fangq opened this issue Feb 3, 2024 · 0 comments

Comments

@fangq
Copy link

fangq commented Feb 3, 2024

this is not a bug, but a question

I am wondering if it is possible to access the underlying TypedArray buffer after .pick or .slice? I noticed that calling .selection.data always returns the full array, not the selected subset.

one need arises from sorting each row of a 2-D matrix. I can achieve this by first calling .tolist() and then call Array.sort

var c = nj.array([[2, 3, 4, 10],[5,6,7,9],[8, 3, 1, 12]]).T;
for(let i=0; i<6; i++) {
  console.log(c.pick(i).tolist().sort((a,b) => a-b));
}

although I would like to do the sorting directly on the TypedArray buffer. is this possible?

also, what is the best way to copy one row/column from one matrix to another?
I tried matrix1.pick(i).assign(matrix2.pick(j)), however, it does not seems to actually copy the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant