我正在尝试使用 C 中的结构对项目进行复杂的向量加法和点积。但是,我编写了我的代码,虽然它正在编译没有问题,但一旦我运行我的程序,它就会停止工作。我还有该程序的其他部分,但这只是相关部分。我也在尝试用复数做矩阵加法和乘法。如果我能让这些工作,我想我可以修改其他人。任何帮助将不胜感激。谢谢,我很感激。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define PI 3.14159265359
typedef struct complex
{
double re;
double im;
}complex;
typedef struct vect_complex
{
double *re;
double *im;
}vect_complex;
typedef struct mat_complex
{
//int i=0,j=0;
double re[100][100];
double im[100][100];
}mat_complex;
void vector_add(vect_complex a[4], vect_complex b[4], vect_complex c[4])
{
int i;
for(i=0; i<3 ;i++);
{
c->re[i] = a->re[i] + b->re[i];
c->im[i] = a->im[i] + b->im[i];
}
printf("Vector addition = (%f + %f*j)i + (%f +%f*j)j + (%f + %f*j)k\n\n",c- >re[0],c->im[0],c->re[1],c->im[1],c->re[2],c->im[2]);
}
void addmx(mat_complex *a, mat_complex *b, mat_complex *c)
{
int i, j;
for ( i = 0 ; i < '\0' ; i++ )
{
for ( j = 0 ; j < '\0' ; j++ )
{
c->re[i][j] = a->re[i][j] + b->re[i][j];
c->im[i][j] = a->im[i][j] + b->im[i][j];
}
}
printf("***Matrix Addition***\n");
for ( i = 0 ; i < '\0' ; i++ )
{
for ( j = 0 ; j < '\0' ; j++ )
{
printf("(%f + %f*j) ", c->re[i][j],c->im[i][j]);
}
printf("\n");
}
}
int main()
{
vect_complex aaa;
vect_complex bbb;
*aaa.re = 5;
*aaa.im = 4;
*bbb.re = 3;
*bbb.im = 2;
vect_complex ccc;
vector_add(&aaa, &bbb, &ccc);
vector_dot_prod(&aaa, &bbb, &ccc);
return 0;
}