#include
int main() {
double x1, x2, x3, x4;
int n1, n2, num;
double theta_or_r1, theta_or_r2;
complex z3, error;
theta_or_r1 = 3;
theta_or_r2 = 4;
z3 = complex(1,2);
/************* test n1 = 1, n2 = 2 ***********/
n1 = 1,
n2 = 2;
num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4);
error = polar(x1, x2) + polar(theta_or_r1, theta_or_r2) - z3;
printf("For n1=1, n2=2, num = %d\n", num);
printf("For n1=1, n2=2, the output x is %f %f %f %f \n", x1, x2, x3, x4);
printf("the residual error is %f \n", error);
/************* test n1 = 1, n2 = 3 ***********/
n1 = 1,
n2 = 3;
num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4);
printf("For n1=1, n2=3, num = %d\n", num);
printf("For n1=1, n2=3, the output x is %f %f %f %f \n", x1, x2, x3, x4);
/************* test n1 = 1, n2 = 4 ***********/
n1 = 1,
n2 = 4;
num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4);
printf("For n1=1, n2=4, num = %d\n", num);
printf("For n1=1, n2=4, the output x is %f %f %f %f \n", x1, x2, x3, x4);
/************* test n1 = 2, n2 = 3 ***********/
n1 = 2,
n2 = 3;
num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4);
printf("For n1=2, n2=3, num = %d\n", num);
printf("For n1=2, n2=3, the output x is %f %f %f %f \n", x1, x2, x3, x4);
/************* test n1 = 2, n2 = 4 ***********/
n1 = 2,
n2 = 4;
num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4);
printf("For n1=2, n2=4, num = %d\n", num);
printf("For n1=2, n2=4, the output x is %f %f %f %f \n", x1, x2, x3, x4);
/************* test n1 = 3, n2 = 4 ***********/
n1 = 3,
n2 = 4;
num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4);
printf("For n1=3, n2=4, num = %d\n", num);
printf("For n1=3, n2=4, the output x is %f %f %f %f \n", x1, x2, x3, x4);
}
For n1=1, n2=2, num = 1
For n1=1, n2=2, the output x is 5.196488 0.964540 NaN NaN
the residual error is complex(0.000000,0.000000)
For n1=1, n2=3, num = 1
For n1=1, n2=3, the output x is 0.654193 -2.520711 NaN NaN
For n1=1, n2=4, num = 2
For n1=1, n2=4, the output x is -4.099052 2.441074 2.683547 0.417334
For n1=2, n2=3, num = 2
For n1=2, n2=3, the output x is -2.467726 -5.116311 1.042948 0.781813
For n1=2, n2=4, num = 2
For n1=2, n2=4, the output x is -0.613277 1.942631 2.827574 0.271667
For n1=3, n2=4, num = 1
For n1=3, n2=4, the output x is 5.196488 0.964540 NaN NaN