//
//  DDERungeKutta23.h
//  DDE23-Test
//
//  Created by ashley on 13/04/2008.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "rhs_protocol.h"

@interface DDERungeKutta23 : NSObject <history> {
	int *_flicked;
	double *_err1;
	double *_s1;
	double *_s2;
	double *_sw1;
	double *_sw2;

	double *_k2;
	double *_k3;
	double *_k4;

	id _history;
	id _rhs;

	int _accepted;
	int _rejected;

	double **_buff;
	double **_gbuff;
	double *_clock;
	double _lastTime;
	double _firstTime;
	long _offset;
	long _size;
	long _no;
	long **_lagmarker;
	double *_his;
	double *_ghis;
	BOOL _first;

}

+ (BOOL) hasHistory;

- (id) initWithRhs:(id)rhs;
- (id) rhs;
- (id) history;
- (int) accepted;
- (int) rejected;
- (BOOL) solve;

- (double) istep:(double *)sw0 newSwitches:(double *)newsws state:(double *)s0 newState:(double *)news 
				gradients:(double*)g newGradients:(double *)newg error:(double *)err 
				startTime:(double)t0 stopTime:(double)t1 /*nsw,ns,*/ flickedSwitch:(int *)flickedswitch success:(BOOL*)success;

- (BOOL) step:(double *)state newState:(double *)newState gradients:(double *)gradients newGradients:(double *)newGradients
			  error:(double *)error time:(double)t timeStep:(double)dt;

- (void) updateHistory:(double *)gradients state:(double *)state time:(double) t;
- (double) pastValue:(int)i time:(double)t mark:(int)markno;

@end