Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail
From: Ralph Schleicher <rs@ralph-schleicher.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: C S Function Rwork vs Global Variables
Date: Tue, 10 Nov 2009 22:10:30 +0100
Organization: Ralph Schleicher
Lines: 19
Message-ID: <87639i3x2x.fsf@echo.mueller-schleicher.i>
References: <hd7eph$p2t$1@fred.mathworks.com>
	<ffb02d67-ff8f-40aa-a463-f588c7a4889f@v25g2000yqk.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.t-online.com 1257890942 00 n6801 tkJ6paHlEHWGSECQ 091110 22:09:02
X-Complaints-To: usenet-abuse@t-online.de
X-ID: E2LscoZTQeBdYeYk2aTtdlwd0+rOFOP6USLtrVU0Yzu7xIWXk40ec-
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:MFRjmgWXlA+OP5h7/BylqozVuY4=
Xref: news.mathworks.com comp.soft-sys.matlab:583986


Praetorian <ashish.sadanandan@gmail.com> writes:

> I'd recommend the first strategy. If you plan on having more than one
> instance of this S-Function in your model, and if these intermediate
> values need to be different for each instance, the global variable
> strategy will fail since global variables are common to all S-Function
> instances.

Simplicity in the implementation rules, therefore use strategy 3).
Multiple pointers don't use that much more memory than one single
pointer.  And 10000 doubles are 80 kiB, that means approx. 13500
instances of your S-function fit into 1 GiB.  Think about that.

-- 
Ralph Schleicher  <http://ralph-schleicher.de>

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools