View unanswered posts | View active topics It is currently Sat Apr 19, 2014 11:54 am






Reply to topic  [ 5 posts ] 
Using standard libraries of functions 
Author Message
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Using standard libraries of functions
Hi,

My first post here ;-)

I want to use some general functions, in this case a student T test, on my nxt. But I rather not program it myself. I also want to use a FIFO stack. My rather dusty C memory tells me I have to include standard libraries that contains these functionality. However, there are no standard libraries for these provided with robotC. Is it possible to use external libraries? If so, what standard do they have to comply to and where to find these?

_________________
My most recent blog: A grain of sugar


Mon Oct 06, 2008 6:41 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: Using standard libraries of functions
Aswin,

They will work provided they don't use pointers of any kind. The way function prototypes are written in RobotC are a little different from "normal" C. You need to specify both argument type and argument name, instead of just argument type. However, writing a FIFO shouldn't be too hard, but there is no such thing as a FIFO stack. A stack is by definition a LIFO :) You're looking for a queue. You could easily implement that with an array and two counters to keep track of your head and tail. There is no "new" or anything like that, so you have to declare your arrays at compile time. I guess you would also need a variable to keep track of the current number of items in your queue if you oversize the array holding it.

Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Oct 07, 2008 2:22 am
Profile WWW
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: Using standard libraries of functions
Xander,

Bedankt (Thanks). The queue itself is the least of my worries. I made one but it wasn't very efficiënt. When trying to improve performance I suddenly realised I was reinventing the wheel.
The student t test is of a different magnitude. It would recire me to write a small libray of basic statistical functions, mean, variance, gamma that build up to the student t test. Also, the best way to write some of these functions is with recursive algorithms. So standard libraries will almost certainly use recursiveness. Realizing this I will go for a more simple alternative.

_________________
My most recent blog: A grain of sugar


Tue Oct 07, 2008 3:30 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: Using standard libraries of functions
Aswin,

Recursion is not supported in RobotC, so you're going to have to come up with some alternative method.

Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Oct 07, 2008 4:07 am
Profile WWW
Rookie

Joined: Sat Apr 19, 2008 11:51 am
Posts: 43
Post Re: Using standard libraries of functions
hi,
aside from recursions, I would also appreciate more transparency to the built-in functions (and functioning).
A good way was structuring all commands by libraries and header files (as it used to be in C).


Wed Oct 08, 2008 9:01 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.