回答編集履歴
1
m
test
CHANGED
@@ -1,3 +1,75 @@
|
|
1
1
|
そもそも論new/deleteを使ってはいけません。そしてあなたが必要なのはおそらくstd::vectorです。
|
2
2
|
|
3
3
|
[https://cpprefjp.github.io/reference/vector/vector.html](https://cpprefjp.github.io/reference/vector/vector.html)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
完全なコードが無いので、適当にリファクタリングしつつ書き換えたのが下です。`Complex`とかいう謎の型も知らんのでとりあえず`std::complex<float>`のエイリアスにしています。`new`しているのは意味不明だったので単に配列にしています。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
```cpp
|
12
|
+
|
13
|
+
constexpr int LOOP1 = 10;
|
14
|
+
|
15
|
+
constexpr int LOOP2 = 15;
|
16
|
+
|
17
|
+
constexpr int L = 5;
|
18
|
+
|
19
|
+
#include <complex>
|
20
|
+
|
21
|
+
#include <iostream>
|
22
|
+
|
23
|
+
using Complex = std::complex<float>;
|
24
|
+
|
25
|
+
void funcA(Complex *in, Complex *pn, int L, int loop2){
|
26
|
+
|
27
|
+
//ここでpn配列の値を決める
|
28
|
+
|
29
|
+
for(int i=0;i<L;i++){
|
30
|
+
|
31
|
+
in[i] *= pn[loop2];
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
int main(void){
|
38
|
+
|
39
|
+
Complex pn[LOOP2];
|
40
|
+
|
41
|
+
Complex in[L];
|
42
|
+
|
43
|
+
for(int loop1=0;loop1<LOOP1;loop1++){
|
44
|
+
|
45
|
+
for(int loop2=0;loop2<LOOP2;loop2++){
|
46
|
+
|
47
|
+
funcA(in, pn, L, loop2);
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
for(auto& p : pn) std::cout << p << std::endl;
|
54
|
+
|
55
|
+
for(auto& i : in) std::cout << i << std::endl;
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
実行結果は
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
[https://wandbox.org/permlink/iiE6kkG0dtJIGpqi](https://wandbox.org/permlink/iiE6kkG0dtJIGpqi)
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
です。特に状況は再現できません。
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
ところで、pnが0のまま演算を進めても全部0のままでは?という思いです。
|