Cool.
I am following the rules in this piece of code I have made to try to pass variables in my bigger proble - to remove the globals.
Code:
#include <stdio.h>
float printarr(int a[], float scalar) {
int i;
float sum = 0;
for(i = 0;i<5;i++) {
sum = (sum + a[i])*scalar;
}
printf("sum = %f\n", sum);
return sum;
}
float brain(int a[], float scalar) {
float sum;
// a and scalar sent to printarr
sum = printarr(a, scalar);
printf("sum = %f\n", sum);
return sum;
}
main()
{
int a[5];
int i;
float sum = 0;
for(i = 0;i<5;i++) {
a[i]=i;
}
float scalar = 5;
//sending brain scalar and array a.
sum = brain(a, scalar);
printf("sum = %f", sum);
}
C is popping up an error on thisline,
Code:
extern status NelderMeadSimplexMethod(n, f, xinit, length, fopt, timeout, eps, float array1[], float array2[]) //array1 and array2 allow two arrays to be passed to another function through NM
apparantly it is expecting a bracket before float.
and then at the beginning of the NelderMead function it says
expected identifier or '(' before '{' token|
Code:
dbl length;
dbl *fopt;
int timeout;
dbl eps;
{
status stat = failure;
int count, i;
nvar = n;
objective = f;
initialize();
initial_simplex(xi
Could anyone explain why because it seems the same method as in the example above, and that runs