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

should init be able to copy i-arrays to k-arrays? #1607

Closed
tomara-x opened this issue May 17, 2022 · 3 comments
Closed

should init be able to copy i-arrays to k-arrays? #1607

tomara-x opened this issue May 17, 2022 · 3 comments

Comments

@tomara-x
Copy link

so kArr[] init iArr would do exactly as kArr[] = iArr but at the init pass only, leaving the k-array free for manipuation (with = it gets recopied in k-time)

@johannphilippe
Copy link

johannphilippe commented May 17, 2022

I had the same issue recently and ended up doing

	kchord[] init isize
	icnt init 0
	while icnt < isize do
		kchord[icnt] init iinp[icnt]
		icnt += 1
	od 

Which could elegantly be replaced by kchord[] init iinp but didn't work in this particular case, when you want to copy an i-rate array to k-rate array just at the init pass.

@vlazzarini
Copy link
Member

vlazzarini commented May 17, 2022

kArr[] init iArr

will only work if iArr is a scalar variable (not an array). Otherwise it is a syntax error.
The meaning of 'init' to arrays is different to scalar variables. It means "create an array with a given size". If you want to create and initialise it, use fillarray

Aside from that, note that k-rate assignment only takes place at perf time.

k.. init ... is a init time expression
k.. = ... is a perf-time expression

So for example,

k1 init 10
print i(k1) // prints 10
k1 = 10
print i(k1) // prints 0 (if the instrument is a new allocation)

I am closing this because there's no issue reported. Please subscribe to the email list or join a forum to ask questions like this.

@tomara-x
Copy link
Author

haha cool entry there! i was thinking either init or fillarray

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

3 participants