- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » define an output array in function...
Page Start Prev 1 Next End
define an output array in function with its size as input
define an output array in function with its size as input
Oct-08-14 17:37:05
Hello,
I have written a function which supposed to calculate bi-nominal coefficients as bellow:
Code:
function binom_coef
input Integer n;
output Integer coef[n+1];
algorithm
for i in 0:n loop
coef[i + 1] := comb(n, i);
end for;
end binom_coef;
class test_binom_coef
parameter Integer n = 3;
parameter Integer a[:] = binom_coef(n);
end test_binom_coef;
in which comb(n,i) calculates combination of k from n.
my question is regarding to binom_coef function which i get n as input and then i want to define a vector of n+1 elements. when i run this code i get the following error:
[:3:3-3:27] Error: Dimensions must be parameter or constant expression (in 1 + n).
please help me with an alternative for this code.
Thanks,
Arvin
Edited by: arvinmor - Oct-08-14 17:37:41
Page Start Prev 1 Next End
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » define an output array in function...
There are 0 guests and 0 other users also viewing this topic