;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; This file is derived from SN-2.8
;;;   Copyright (C) 1987-1999 Neuristique s.a.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; $Id: plot-nlf.sn,v 1.1 2003/03/18 18:17:14 leonb Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;
; plots the NLF, and its first and second derivatives
;
; LYB -- Nov 8, 1988
;
                                                    
(de plot-nlf(x1 x2)

   (if ~plot-nlf-window
       (let ((window window))                                   ; saves the current window !
         (setq plot-nlf-window (new-window "NLF")) ) )

   (let* ( (x (range x1 x2 (/ (- x2 x1) 100)))
           (y (all ((i x)) (nlf i)))	
           (y1 (all ((i x)) (dnlf i)))	
           (y2 (all ((i x)) (ddnlf i)))

           (maxy (max (sup y) (sup y1) (sup y2) 1))
           (miny (min (inf y) (inf y1) (inf y2) -1))
           (maxx (max x1 x2 1))
           (minx (min x1 x2 -1))
           (xlabel (list 1  0 -1 minx maxx))
           (ylabel (list 1  0 -1 miny maxy))

           (window plot-nlf-window)
           (brect (list 60 (- (ysize) 30) (- (xsize) 50) 40 )) 
           (rrect (list minx miny maxx maxy))
           (plot-port (new-plot-port brect rrect object-nil))

           (oldcolor (color))
           (oldfont  (font)) )
   
        (color color-fg)
        (cls)
        (draw-axes brect xlabel ylabel "Non linear function and derivatives")
        (graphics-batch (plot-lists x y))
        (graphics-batch (plot-lists x y1))
        (graphics-batch (plot-lists x y2))

        (color oldcolor)
        (font oldfont) ) )

   

