索引多个非相邻的数组元素fortran [英] index multiple non-adjacent array elements fortran
本文介绍了索引多个非相邻的数组元素fortran的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如给定100个元素的数组
real(100):: a
我可以这样做来访问不遵循常规步骤的元素1,4,7,54,81吗?
a(1,4,7,54,81)= 3.21423
解决方案
您可以使用向量下标: a((/ 1,4,7,54,81 /))= 3.21423
Is there a way in fortran to access many elements of an array outside of a loop? For example given array of 100 elements
real(100) :: a
can I do something like this to access elements 1,4,7,54,81 that do not follow a regular step?
a(1,4,7,54,81)= 3.21423
解决方案
you could use a vector subscript: a( (/1,4,7,54,81/) )= 3.21423
这篇关于索引多个非相邻的数组元素fortran的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文