ftp.nice.ch/pub/next/science/mathematics/HippoDraw.2.0.s.tar.gz#/HippoDraw/Hippo.bproj/Exponential.m

This is Exponential.m in view mode; [Download] [Up]

/* Exponential.m
 * 
 * Paul Rensing Mar 5, 1993
 *
 * Subclass of PFunction to manage an exponential function
 *
 * Copyright (C)  1993  The Board of Trustees of
 * The Leland Stanford Junior University. All Rights Reserved.
 */

#import "Exponential.h"

const char Exponential_h_rcsid[] = EXPONENTIAL_H_ID;
const char Exponential_m_rcsid[] = "$Id: Exponential.m,v 1.1 1993/03/10 20:12:27 rensing Exp $";

#import <objc/Storage.h>
#include <math.h>

@implementation Exponential 

static double exponential( double x, double binW, double *par )
{
    return binW * par[0] * exp( par[1] * x );
}

- init
{
    [super init];
    [[[self setTitle:"Exponential"] setFunctionPtr:exponential] setNumberArgs:2];
    [self registerFunc];	/* must be called after the above */
    [self setArgName:"Norm" at:0];
    [self setArgName:"ExpSlope" at:1];
    return self;
}

- setInitialValues
{
    fitParm            *parm;
    graphtype_t         type;

    [super setInitialValues];
    if (!disp)
	return self;

    type = h_getDispType(disp);

    parm = [variedParms elementAt:0];
    parm->lower_limit = disp->yAxis.low;
    parm->upper_limit = disp->yAxis.high;
    parm->value = 0.8 * parm->upper_limit;
    parm->step_size = 0.01 * (disp->yAxis.high - disp->yAxis.low);

    parm = [variedParms elementAt:1];
    if (disp->yAxis.low > 0)
	parm->upper_limit = (log(disp->yAxis.high) - log(disp->yAxis.low))
	  / (disp->xAxis.high - disp->xAxis.low);
    else
	parm->upper_limit = 10.0;
    parm->lower_limit = -parm->upper_limit;
    parm->step_size = 0.02 * fabs(parm->upper_limit);
    parm->value = 0.0;

    return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.