Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scheme 高斯函数及其在格式中的应用_Scheme_Gaussian_Currying - Fatal编程技术网

Scheme 高斯函数及其在格式中的应用

Scheme 高斯函数及其在格式中的应用,scheme,gaussian,currying,Scheme,Gaussian,Currying,我目前正在尝试学习运行FDTD模拟的方案,但在构建二维高斯函数时遇到了困难 在一个论坛上,我发现了1D的这种可能性: (define ( (gaussx sigma) x) (exp (- (/ (vector3-dot x x) (* 2 sigma sigma))))) 如果我理解正确,咖喱相当于: (define (gauss sigma) (lambda(x) (exp (- (/ (vector3-dot x x) (* 2 sigma sigma)))))

我目前正在尝试学习运行FDTD模拟的方案,但在构建二维高斯函数时遇到了困难

在一个论坛上,我发现了1D的这种可能性:

(define ( (gaussx sigma) x)
   (exp (- (/ (vector3-dot x x) (* 2 sigma sigma)))))
如果我理解正确,咖喱相当于:

(define  (gauss sigma)
   (lambda(x)
      (exp (- (/ (vector3-dot x x) (* 2 sigma sigma))))))
现在我希望函数沿x和y方向都是高斯函数,但我不明白为什么这不起作用:

(define  (gauss sigma)
   (lambda(x)
      (lambda(y)
         (exp (- (/ (+ (vector3-dot y y) (vector3-dot x x)) (* 2 sigma sigma))))
当我打电话时

(gauss 1)
我得到以下信息:

ERROR: Wrong type (expecting real number): # <procedure> #f (y)
错误:错误类型(应为实数):##f(y)
有人知道我做错了什么吗?我也尝试过其他解决方案,但我似乎不明白这里的逻辑

非常感谢你的帮助

致意
Mei

我认为这里不需要双咖喱,试试这个:

(define (gauss sigma)
  (lambda (x y)
    (exp (- (/ (+ (vector3-dot y y) (vector3-dot x x)) (* 2 sigma sigma))))))
可以这样称呼:

(define gauss-1 (gauss 1))
(gauss-1 some-x some-y)
(define gauss-1 (gauss 1))
((gauss-1 some-x) some-y)
但如果您确实需要双咖喱,这应该可以:

(define (gauss sigma)
  (lambda (x)
    (lambda (y)
      (exp (- (/ (+ (vector3-dot y y) (vector3-dot x x)) (* 2 sigma sigma)))))))
像这样使用它:

(define gauss-1 (gauss 1))
(gauss-1 some-x some-y)
(define gauss-1 (gauss 1))
((gauss-1 some-x) some-y)