In the following program calculates the determinant in c via Octave. But i don´t know how to pass the variable from octave to c:
#include <stdio.h>
int main(void)
{
FILE *graf;
graf=popen("octave -persist","w");
if (graf==NULL){
printf("Error \n");}
else
{
int a;
printf("input the dimension: \n");
scanf("%d",&a);
fprintf(graf,"N= %d;",a);
fprintf(graf,"pkg load statistics \n");
fprintf(graf,"M=N-1;");
fprintf(graf," for i=1:%d \n",a);
fprintf(graf," for j=1:%d \n",a);
fprintf(graf," matriz(i,j)=round(1+9*rand());");
fprintf(graf," endfor \n");
fprintf(graf,"endfor \n");
fprintf(graf,"C = combnk(1:%d,M);",a);
fprintf(graf,"Combinaciones=size(C,1);");
fprintf(graf,"for i=1:Combinaciones \n");
fprintf(graf,"for j=1:Combinaciones \n");
fprintf(graf,"for h=1:M \n");
fprintf(graf,"for k=1:M \n");
fprintf(graf,"matrices(h,k)=matriz(C(i,h),C(j,k));");
fprintf(graf,"endfor \n");
fprintf(graf,"endfor \n");
fprintf(graf,"nuevamatriz(Combinaciones-i+1,Combinaciones-j+1)=det(matrices);");
fprintf(graf,"endfor \n");
fprintf(graf,"endfor \n");
fprintf(graf,"matriz \n");
fprintf(graf,"det(matriz) \n");
fprintf(graf,"nuevamatriz \n");
fprintf(graf,"det(nuevamatriz) \n");
pclose(graf);
}
printf("Have that the second determinant (attached matrix) is always the first (matrix) powered at dimension less one \n\n ");
}
A way to define this determining variable in c.