张量(Tensor)
张量(Tensor):表示某种相同数据类型的多维数组。
0阶tensor = 标量(Scalar)2
1阶tensor = 向量(Vector)[1, 2, 3, 4] -> [1] = 2
2阶tensor = 矩阵(Matrix)[[1, 2], [3, 4]] -> [0][1] = 2
3阶tensor = 立方(Cube)[[[1], [2]], [[3], [4]]] -> [0][1][0] = 2
n阶tensor = …
#include <iostream>
using namespace std;
const int N = 5;
int a[N][N][N];
int main()
{
int s = 0;
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
for (int k = 0; k < N; ++k)
a[i][j][k] = ++s;
}
s = 0;
}
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
for (int k = 0; k < N; ++k)
cout << a[i][j][k] << " ";
puts("");
}
puts("");
}
return 0;
}