math - fortran 坐标函数 f(x)
问题描述
我需要在 FORTRAN 90 中进行一些数学计算。为此,我需要使用其他函数的坐标函数。一个例子如下
program test1
implicit none
integer :: i, Nend
double precision :: step, a, b
double precision, dimension(:), allocatable :: t
Nfim = 10
a = 0.d0
b = 1.d0
step = (b-a)/Nend
allocate(t(0:Nfim))
t(0) = a
do i=0,Nfim
t(i+1) = t(i) + step
write(*,*) i, t(i), f(t(i)),g(t(i))
end do
contains
function f(x)
implicit none
double precision :: f
double precision, dimension(2) :: f
f(1) = x-1.d0
f(2) = 2.d0*x
return
end function
function g(x)
implicit none
double precision :: x, g
g = f(1)(x)+2.d0*f(2)(x)
return
end function
end program
我提示我有回报
34 | g = f(1)(x)+2.d0*f(2)(x)
| 1
Error: Invalid character in name at (1)
我确实明白,在 f(...) 中,''...'' = x 而不是 ''...'' = 1。我不喜欢使用 f1,因为在我的程序中,维度函数 f 将是可变的,该程序将适用于其他情况,这将为我节省一些时间。你能帮助我吗?现在谢谢你!
解决方案
推荐阅读
- go - Go Golang net.Dial 发送 1 个请求但读取第二个响应
- node.js - 如何将转译的 babel 文件中的错误映射回源代码?
- scala - Scala中这两个代码段有什么区别
- cucumber - cucumber-jvm 上 .feature 文件的默认位置是什么?
- xml - 如何修复 xml-document 中的“标记必须格式正确”错误
- php - 写在一行上的 HTML 多个代码任务
- c - ASCII 字符没有被打印出来
- node.js - 运行离子时如何解决“构建失败,错误代码:1”?
- ruby - 如何使用 httparty 而不是 net/http 或 curl
- r - 在R中获取模式匹配之后和之前的字符