On Tue, 27 Jun 2006, David Leuenberger wrote:
I am little bit confused with the syntax of the function and the reference
manual doesn't help me:

"(max-abs-field-function cs func [where] [fields-var])"

func is a function of position (a vector3, its first argument) and zero or
more field components specified by cs: a list of component constants. func
can be real- or complex-valued.

Let's just consider the case where one would like to calculate the maximum
of |E|^2
in the entire computational domain.

My guess was:
meep> (define ((myfunc Ex Ey) x) (+ (* Ex (conj Ex)) (* Ey (conj Ey))))

x needs to be the first argument, as pointed out in the manual.  e.g.

(define (myfunc x ex ey) (+ (sqr (magnitude ex)) (sqr (magnitude ey))))

meep>  (max-abs-field-function Ex Ey (myfunc Ex Ey))

The first argument must be a *list* of component constants. The second argument must be a function of the field components, not the *result* of calling such a function. e.g.

(max-abs-field-function (list Ex Ey) myfunc)

(The distinction between a function, myfunc, and the result (myfunc Ex Ey) of calling a function, seems to be the most common confusion for users new to functional languages like Scheme.)

Steven

_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to