Vector Arguments in Functions Part 2
Posted: Mon Sep 25, 2017 7:33 pm
Consider a user-defined dyadic function Cone5.
Ans←Fstream Cone5 Thetas
Arguments are: Fstream←1.4 2.2 287 300 100 50
and Thetas which is a input angle in radians.
The elements of Fstream are fixed for the remainder of this Forum post.
If run for a single input angle, say, Thetas←0.8,
Ans←Fstream Cone5 0.8
The result Ans is a 50 row, 7 column matrix,i.e., ⍴Ans is 50 7. The individual elements in Ans can be accessed as usual, e.g., Ans[40;5]. The difficulty occurs when the argument Thetas becomes a vector. For example, Thetas←0.8 0.9 1.0. The current method uses the Each Operator:
Ans←Fstream Fstream Fstream Cone5¨ 0.8 0.9 1.0
⍴Ans is now 3 and it appears that the result Ans is now a nested array with Ans[1] being the first 50 row, 7 column matrix; Ans[2] being the second 50 row, 7 column matrix; and, Ans[3] being the third 50 row, 7 column matrix. Numerically, the results are correct. However, I have not been able to access the individual elements in the result. Question 1: How do I access the individual elements in the result? Attempts such as (Ans[1])[40;5] or 40 5⌷Ans[1] do not work. Question 2: How could the result Ans be assigned to a rank 3 array with shape 3 50 7?
Any suggestions would be welcome.
Ans←Fstream Cone5 Thetas
Arguments are: Fstream←1.4 2.2 287 300 100 50
and Thetas which is a input angle in radians.
The elements of Fstream are fixed for the remainder of this Forum post.
If run for a single input angle, say, Thetas←0.8,
Ans←Fstream Cone5 0.8
The result Ans is a 50 row, 7 column matrix,i.e., ⍴Ans is 50 7. The individual elements in Ans can be accessed as usual, e.g., Ans[40;5]. The difficulty occurs when the argument Thetas becomes a vector. For example, Thetas←0.8 0.9 1.0. The current method uses the Each Operator:
Ans←Fstream Fstream Fstream Cone5¨ 0.8 0.9 1.0
⍴Ans is now 3 and it appears that the result Ans is now a nested array with Ans[1] being the first 50 row, 7 column matrix; Ans[2] being the second 50 row, 7 column matrix; and, Ans[3] being the third 50 row, 7 column matrix. Numerically, the results are correct. However, I have not been able to access the individual elements in the result. Question 1: How do I access the individual elements in the result? Attempts such as (Ans[1])[40;5] or 40 5⌷Ans[1] do not work. Question 2: How could the result Ans be assigned to a rank 3 array with shape 3 50 7?
Any suggestions would be welcome.