ConstantArray[c,n]
生成元素 c 的 n 个副本的列表.
ConstantArray[c,{n1,n2,…}]
生成一个
数组,它包括元素 c 的副本的嵌套列表.
ConstantArray
ConstantArray[c,n]
生成元素 c 的 n 个副本的列表.
ConstantArray[c,{n1,n2,…}]
生成一个
数组,它包括元素 c 的副本的嵌套列表.
更多信息
- ConstantArray[c,n,SparseArray] 给出常量数组,作为 SparseArray 对象.
范例
打开所有单元 关闭所有单元基本范例 (3)
范围 (4)
ConstantArray[0., 10]ConstantArray[0, 10]zm = ConstantArray[0., {3, 3}]ConstantArray[0, {3, 3}]ConstantArray[1, 10]ConstantArray[1., 10]ConstantArray[x, {2, 1, 2, 1, 2}]应用 (3)
esteps[f_, x0_, h_, n_] := Module[{res = ConstantArray[x0, {n + 1}], x = x0},
Do[x += h f[i h, x];res[[i + 1]] = x, {i, n}];res]用欧拉方法求 x'[t]==1/(t+x[t]^2) 的数值解:
sol = esteps[Function[{t, x}, 1 / (t + x ^ 2)], 1, .01, 100];ListPlot[sol, DataRange -> {0, 1}]list = RandomInteger[9, 20]list.ConstantArray[1, Length[list]]这也可以用 Total 得到:
Total[list]ones = ConstantArray[1, 10]m = HilbertMatrix[10];
b = m.ones;x = LinearSolve[N[m], b]
Norm[x - ones]x30 = LinearSolve[N[m, 30], b];
Norm[Block[{$MaxPrecision = 30, $MinPrecision = 30}, x30 - ones]]属性和关系 (3)
ConstantArray[c,dims] 有 Dimensions[dims]:
dims = RandomInteger[{1, 4}, 5]Dimensions[ConstantArray[c, dims]]ConstantArray[c,dims] 等于 SparseArray[{},dims,c]:
dims = RandomInteger[{1, 4}, 5];s = SparseArray[{}, dims, c]ConstantArray[c, dims] == sNormal[s] 与 ConstantArray[c,dims] 相同:
ConstantArray[c, dims] === Normal[s]ConstantArray[c,dims] 等价于 Apply[Table[c,##]&,Map[List,dims]]:
dims = RandomInteger[{1, 4}, 5];ConstantArray[c, dims] === Apply[Table[c, ##]&, Map[List, dims]]文本
Wolfram Research (2007),ConstantArray,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ConstantArray.html (更新于 2008 年).
CMS
Wolfram 语言. 2007. "ConstantArray." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2008. https://reference.wolfram.com/language/ref/ConstantArray.html.
APA
Wolfram 语言. (2007). ConstantArray. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ConstantArray.html 年
BibTeX
@misc{reference.wolfram_2026_constantarray, author="Wolfram Research", title="{ConstantArray}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/ConstantArray.html}", note=[Accessed: 14-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_constantarray, organization={Wolfram Research}, title={ConstantArray}, year={2008}, url={https://reference.wolfram.com/language/ref/ConstantArray.html}, note=[Accessed: 14-September-2026]}