質問編集履歴
2
修正いたしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
### 発生している問題・エラーメッセージ
|
8
8
|
#### makeとした時のエラー
|
9
9
|
```
|
10
|
-
make: *** [matrix.o] Error 1
|
10
|
+
make: *** [matrix.o] Error 1
|
11
11
|
```
|
12
12
|
### 今したいこと
|
13
13
|
|
1
解答をもとに修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,26 +5,30 @@
|
|
5
5
|
以下のエラーメッセージが発生しました。
|
6
6
|
|
7
7
|
### 発生している問題・エラーメッセージ
|
8
|
+
#### makeとした時のエラー
|
9
|
+
```
|
10
|
+
make: *** [matrix.o] Error 1だけになりました。
|
11
|
+
```
|
12
|
+
### 今したいこと
|
8
13
|
|
9
|
-
```
|
10
|
-
|
14
|
+
matrixmain内の、%lf + %lfiの部分を、
|
11
|
-
Undefined symbols for architecture arm64:
|
12
|
-
"_free_mat", referenced from:
|
13
|
-
|
15
|
+
それぞれ実部虚部に入れたいのですが、
|
14
|
-
|
16
|
+
&mat[i][j].re, &mat[i][j].im
|
17
|
+
ではできませんでした。教えていただけるとありがたいです。
|
15
|
-
|
18
|
+
complexについては、
|
16
|
-
"_print_mat", referenced from:
|
17
|
-
_main in matrixmain.o
|
18
|
-
ld: symbol(s) not found for architecture arm64
|
19
|
-
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
20
|
-
|
19
|
+
typedef struct complex {
|
20
|
+
double re;
|
21
|
+
double im;
|
22
|
+
} complex ;
|
21
|
-
|
23
|
+
となっております
|
24
|
+
|
22
25
|
|
23
26
|
### 該当のソースコード
|
24
27
|
##### matrixmain.c
|
25
28
|
|
26
29
|
```C
|
27
30
|
#include <stdio.h>
|
31
|
+
#include <stdlib.h>
|
28
32
|
#include "complex.h"
|
29
33
|
#include "matrix.h"
|
30
34
|
|
@@ -53,6 +57,8 @@
|
|
53
57
|
#include "complex.h"
|
54
58
|
#include "matrix.h"
|
55
59
|
#include <math.h>
|
60
|
+
#include <stdio.h>
|
61
|
+
#include <stdlib.h>
|
56
62
|
|
57
63
|
complex** init_mat( FILE* fp, int n, int m){
|
58
64
|
complex ** mat;
|
@@ -62,7 +68,7 @@
|
|
62
68
|
mat[i] = (complex *)malloc(sizeof(complex) * m);
|
63
69
|
for(int i = 0;i < n;i++){
|
64
70
|
for(int j = 0;j < m;j++)
|
65
|
-
fscanf(fp, "%lf + %lfi", &mat[i][j]);
|
71
|
+
fscanf(fp, "%lf + %lfi", &mat[i][j].re, &mat[i][j].im);
|
66
72
|
}
|
67
73
|
return mat;
|
68
74
|
}
|
@@ -74,7 +80,7 @@
|
|
74
80
|
void print_mat( complex** mat, int n, int m){
|
75
81
|
for(int i = 0;i < n;i++){
|
76
82
|
for(int j = 0;j < m;j++)
|
77
|
-
printf("\tlf + %lfi", mat[i][j]);
|
83
|
+
printf("\tlf + %lfi", &mat[i][j].re, &mat[i][j].im);
|
78
84
|
printf("\n");
|
79
85
|
}
|
80
86
|
}
|