Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

linspace

yingwu
Beginner
2,787 Views
Could I ask whether this is any Fortran funtion like the function linspace() in matlab? Or I need to implement it by myself. Thanks.
0 Kudos
1 Solution
Les_Neilson
Valued Contributor II
2,787 Views
Quoting - yingwu
Could I ask whether this is any Fortran funtion like the function linspace() in matlab? Or I need to implement it by myself. Thanks.

You could use an array construct. Something along the lines of :

real y(100)
real a
integer i

a = 1.5 ! Initial value

y = (/((i*a),i=1,100)/) ! assign to y in increments of 1.5 starting at 1.5


Les

View solution in original post

0 Kudos
2 Replies
Les_Neilson
Valued Contributor II
2,788 Views
Quoting - yingwu
Could I ask whether this is any Fortran funtion like the function linspace() in matlab? Or I need to implement it by myself. Thanks.

You could use an array construct. Something along the lines of :

real y(100)
real a
integer i

a = 1.5 ! Initial value

y = (/((i*a),i=1,100)/) ! assign to y in increments of 1.5 starting at 1.5


Les
0 Kudos
yingwu
Beginner
2,787 Views
Quoting - Les Neilson

You could use an array construct. Something along the lines of :

real y(100)
real a
integer i

a = 1.5 ! Initial value

y = (/((i*a),i=1,100)/) ! assign to y in increments of 1.5 starting at 1.5


Les


Thanks so much. It is very helpful.
0 Kudos
Reply