From help-octave-request at bevo dot che dot wisc dot edu Fri Jan 19 10:12:10 2001 Subject: Re: .oct-files/ library-wrapper From: Ben Sapp To: Daniel Heiserer CC: "help-octave at bevo dot che dot wisc dot edu" Date: Fri, 19 Jan 2001 09:12:12 -0700 Daniel Heiserer wrote: > > Hi, . . . > How do I know what kind of datatype is args(j)? in octave/src/ov.h There are a number of functions defined to determine the data type. They are: is_cell(); is_real_scalar(); is_real_matrix(); is_complex_scalar(); is_complex_matrix(); is_char_matrix(); is_string(); is_range(); is_map(); is_stream(); is_list(); is_magic_colon(); is_all_va_args(); is_bool_type(); is_real_type(); is_complex_type(); is_scalar_type(); is_matrix_type(); is_numeric_type(); Then once you determine the correct type you can get it representation with something like: ComplexRowVector = args(0).complex_row_vector_value(); If the data type is a new data type the above "is_" function won't be of much use. Then you will have to use a technique similar to what is used in examples/make_int.cc(Look at the "doit" dynamically linked function.) > How do I define multiple output arguments is it the same > by just creating a list? > retval(1) = a; > retval(0) = b; I don't think that will work. Below is a small example that will work. You use the third arguement to your DLD function to find out how many arguements are asked for on the command line. Then you add elements to the list by using the append and prepend member functions. mlist source: ----------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include DEFUN_DLD(mlist,args,nargout, "return a variable number of arguments.") { octave_value_list retval; for (int i = 0;i < nargout;i++) { retval.append(octave_value(double(i+1))); } return retval; } -------------------------------------------------- On my machine some sample output looks like so: octave:2> a = mlist a = 1 octave:3> [a,b] = mlist a = 1 b = 2 octave:4> [a,b,c] = mlist a = 1 b = 2 c = 3 octave:5> [a,b,c,d] = mlist a = 1 b = 2 c = 3 d = 4 Lastly, as far as a library wrapper, I do not know of any. Good luck. -- Ben Sapp Los Alamos National Laboratory email: Phone: (505)667-3277 Fax: (505)665-7920 URL: http://www.neutrino.lanl.gov/ -- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------