Lukas Reichlin | 10 Feb 08:10
Picon

How to combine several functions in a single oct-file?

Dear Octave community,

I noticed that "which arrayfun" points to cellfun.oct (octave 3.6.0). This means that both arrayfun and
cellfun are stored in a single oct-file. Now I wonder how octave knows that it finds arrayfun in
cellfun.oct? Does octave load all oct-files on startup? I thought that a function "foo" has to be located
in foo.m, foo.oct or in the same m-file as the calling function.

Background: My control package has dozens of oct-files and I like to combine them in just a few oct-files.
They all use the SLICOT Fortran library and I compiled the required parts of it into every single oct-file.
I think it would be better if the Fortran code would be stored in one big oct-file that offers all the user
functions. Like cellfun.oct.

Thanks for any insights and best regards,
Lukas
Michael Goffioul | 10 Feb 09:59
Picon

Re: How to combine several functions in a single oct-file?

On Fri, Feb 10, 2012 at 7:10 AM, Lukas Reichlin
<lukas.reichlin <at> gmail.com> wrote:
> Dear Octave community,
>
> I noticed that "which arrayfun" points to cellfun.oct (octave 3.6.0). This means that both arrayfun and
cellfun are stored in a single oct-file. Now I wonder how octave knows that it finds arrayfun in
cellfun.oct? Does octave load all oct-files on startup? I thought that a function "foo" has to be located
in foo.m, foo.oct or in the same m-file as the calling function.
>
> Background: My control package has dozens of oct-files and I like to combine them in just a few oct-files.
They all use the SLICOT Fortran library and I compiled the required parts of it into every single oct-file.
I think it would be better if the Fortran code would be stored in one big oct-file that offers all the user
functions. Like cellfun.oct.
>
> Thanks for any insights and best regards,
> Lukas

What you're looking for is "autoload". This allows you to tell octave
"this function is found in that oct-file". See
<octave_root>/lib/≤octave_version>/oct/≤arch>/PKG_ADD file in your
octave installation.

Michael.
Carlo de Falco | 10 Feb 09:50
Picon

Re: How to combine several functions in a single oct-file?

2012/2/10 Lukas Reichlin <lukas.reichlin <at> gmail.com>:
> Dear Octave community,
>
> I noticed that "which arrayfun" points to cellfun.oct (octave 3.6.0). This means that both arrayfun and
cellfun are stored in a single oct-file. Now I wonder how octave knows that it finds arrayfun in
cellfun.oct? Does octave load all oct-files on startup? I thought that a function "foo" has to be located
in foo.m, foo.oct or in the same m-file as the calling function.
>
> Background: My control package has dozens of oct-files and I like to combine them in just a few oct-files.
They all use the SLICOT Fortran library and I compiled the required parts of it into every single oct-file.
I think it would be better if the Fortran code would be stored in one big oct-file that offers all the user
functions. Like cellfun.oct.
>
> Thanks for any insights and best regards,
> Lukas
>

Have a look at the command "autoload", it should do what you ask,
you can also look at the PKG_ADD commands in packages combinatorics
and odepkg for inspiration.

If you use this approach, be aware that it has some side effects:
http://octave.1599824.n4.nabble.com/reverse-of-autoload-tp1635126p1635126.html

HTH,
c.
Michael Goffioul | 12 Feb 23:12
Picon

Re: How to combine several functions in a single oct-file?

On Fri, Feb 10, 2012 at 8:50 AM, Carlo de Falco <carlo.defalco <at> gmail.com> wrote:
> 2012/2/10 Lukas Reichlin <lukas.reichlin <at> gmail.com>:
>> Dear Octave community,
>>
>> I noticed that "which arrayfun" points to cellfun.oct (octave 3.6.0). This means that both arrayfun and
cellfun are stored in a single oct-file. Now I wonder how octave knows that it finds arrayfun in
cellfun.oct? Does octave load all oct-files on startup? I thought that a function "foo" has to be located
in foo.m, foo.oct or in the same m-file as the calling function.
>>
>> Background: My control package has dozens of oct-files and I like to combine them in just a few oct-files.
They all use the SLICOT Fortran library and I compiled the required parts of it into every single oct-file.
I think it would be better if the Fortran code would be stored in one big oct-file that offers all the user
functions. Like cellfun.oct.
>>
>> Thanks for any insights and best regards,
>> Lukas
>>
>
> Have a look at the command "autoload", it should do what you ask,
> you can also look at the PKG_ADD commands in packages combinatorics
> and odepkg for inspiration.
>
> If you use this approach, be aware that it has some side effects:
> http://octave.1599824.n4.nabble.com/reverse-of-autoload-tp1635126p1635126.html

There is (or used to be) the PKG_DEL counterpart to PKG_ADD. But
what's missing is autounload (such feature request makes sense imo).
The other possibility is to put all the common code into a single
shared library, then link all oct-files to that library.

(Continue reading)

Lukas Reichlin | 12 Feb 23:36
Picon

Re: How to combine several functions in a single oct-file?


On 12.02.2012, at 23:12, Michael Goffioul wrote:

> On Fri, Feb 10, 2012 at 8:50 AM, Carlo de Falco <carlo.defalco <at> gmail.com> wrote:
>> 2012/2/10 Lukas Reichlin <lukas.reichlin <at> gmail.com>:
>>> Dear Octave community,
>>> 
>>> I noticed that "which arrayfun" points to cellfun.oct (octave 3.6.0). This means that both arrayfun
and cellfun are stored in a single oct-file. Now I wonder how octave knows that it finds arrayfun in
cellfun.oct? Does octave load all oct-files on startup? I thought that a function "foo" has to be located
in foo.m, foo.oct or in the same m-file as the calling function.
>>> 
>>> Background: My control package has dozens of oct-files and I like to combine them in just a few
oct-files. They all use the SLICOT Fortran library and I compiled the required parts of it into every
single oct-file. I think it would be better if the Fortran code would be stored in one big oct-file that
offers all the user functions. Like cellfun.oct.
>>> 
>>> Thanks for any insights and best regards,
>>> Lukas
>>> 
>> 
>> Have a look at the command "autoload", it should do what you ask,
>> you can also look at the PKG_ADD commands in packages combinatorics
>> and odepkg for inspiration.
>> 
>> If you use this approach, be aware that it has some side effects:
>> http://octave.1599824.n4.nabble.com/reverse-of-autoload-tp1635126p1635126.html
> 
> There is (or used to be) the PKG_DEL counterpart to PKG_ADD. But
> what's missing is autounload (such feature request makes sense imo).
(Continue reading)

Lukas Reichlin | 13 Feb 00:01
Picon

Re: How to combine several functions in a single oct-file? (2)

On 12.02.2012, at 23:36, Lukas Reichlin wrote:

> 
> On 12.02.2012, at 23:12, Michael Goffioul wrote:
> 
>> On Fri, Feb 10, 2012 at 8:50 AM, Carlo de Falco <carlo.defalco <at> gmail.com> wrote:
>>> 2012/2/10 Lukas Reichlin <lukas.reichlin <at> gmail.com>:
>>>> Dear Octave community,
>>>> 
>>>> I noticed that "which arrayfun" points to cellfun.oct (octave 3.6.0). This means that both arrayfun
and cellfun are stored in a single oct-file. Now I wonder how octave knows that it finds arrayfun in
cellfun.oct? Does octave load all oct-files on startup? I thought that a function "foo" has to be located
in foo.m, foo.oct or in the same m-file as the calling function.
>>>> 
>>>> Background: My control package has dozens of oct-files and I like to combine them in just a few
oct-files. They all use the SLICOT Fortran library and I compiled the required parts of it into every
single oct-file. I think it would be better if the Fortran code would be stored in one big oct-file that
offers all the user functions. Like cellfun.oct.
>>>> 
>>>> Thanks for any insights and best regards,
>>>> Lukas
>>>> 
>>> 
>>> Have a look at the command "autoload", it should do what you ask,
>>> you can also look at the PKG_ADD commands in packages combinatorics
>>> and odepkg for inspiration.
>>> 
>>> If you use this approach, be aware that it has some side effects:
>>> http://octave.1599824.n4.nabble.com/reverse-of-autoload-tp1635126p1635126.html
>> 
(Continue reading)

Michael Goffioul | 13 Feb 00:47
Picon

Re: How to combine several functions in a single oct-file? (2)

On Sun, Feb 12, 2012 at 11:01 PM, Lukas Reichlin
<lukas.reichlin <at> gmail.com> wrote:
>>> There is (or used to be) the PKG_DEL counterpart to PKG_ADD. But
>>> what's missing is autounload (such feature request makes sense imo).
>>> The other possibility is to put all the common code into a single
>>> shared library, then link all oct-files to that library.
>>>
>>> Michael.
>>
>> Hi Michael,
>>
>> I like your idea of a single shared library very much. Is it possible to create such a library out of SLICOT
upon package installation? It would be nice if I could link it the same way as the BLAS and LAPACK libraries.
>>
>> Best regards,
>> Lukas
>
> PS: I would like to include the archive slicot.tar.gz [1] in my package. Then, upon package installation,
it should be unpacked and compiled to a library I can link to. Until now, I have to add all files by hand, which
is quite ugly [2].
>
> Lukas
>
> [1] SLICOT Library
> http://www.slicot.org/shared/slicot.tar.gz
>
> [2] Makefile of the control package
> http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/src/Makefile?revision=9513&view=markup
>

(Continue reading)

Lukas Reichlin | 13 Feb 07:55
Picon

Re: How to combine several functions in a single oct-file? (2)


On 13.02.2012, at 00:47, Michael Goffioul wrote:

> On Sun, Feb 12, 2012 at 11:01 PM, Lukas Reichlin
> <lukas.reichlin <at> gmail.com> wrote:
>>>> There is (or used to be) the PKG_DEL counterpart to PKG_ADD. But
>>>> what's missing is autounload (such feature request makes sense imo).
>>>> The other possibility is to put all the common code into a single
>>>> shared library, then link all oct-files to that library.
>>>> 
>>>> Michael.
>>> 
>>> Hi Michael,
>>> 
>>> I like your idea of a single shared library very much. Is it possible to create such a library out of SLICOT
upon package installation? It would be nice if I could link it the same way as the BLAS and LAPACK libraries.
>>> 
>>> Best regards,
>>> Lukas
>> 
>> PS: I would like to include the archive slicot.tar.gz [1] in my package. Then, upon package
installation, it should be unpacked and compiled to a library I can link to. Until now, I have to add all
files by hand, which is quite ugly [2].
>> 
>> Lukas
>> 
>> [1] SLICOT Library
>> http://www.slicot.org/shared/slicot.tar.gz
>> 
>> [2] Makefile of the control package
(Continue reading)

Michael Goffioul | 13 Feb 10:17
Picon

Re: How to combine several functions in a single oct-file? (2)

On Mon, Feb 13, 2012 at 6:55 AM, Lukas Reichlin
<lukas.reichlin <at> gmail.com> wrote:
>>>>> Michael.
>>>>
>>>> Hi Michael,
>>>>
>>>> I like your idea of a single shared library very much. Is it possible to create such a library out of
SLICOT upon package installation? It would be nice if I could link it the same way as the BLAS and LAPACK libraries.
>>>>
>>>> Best regards,
>>>> Lukas
>>>
>>> PS: I would like to include the archive slicot.tar.gz [1] in my package. Then, upon package
installation, it should be unpacked and compiled to a library I can link to. Until now, I have to add all
files by hand, which is quite ugly [2].
>>>
>>> Lukas
>>>
>>> [1] SLICOT Library
>>> http://www.slicot.org/shared/slicot.tar.gz
>>>
>>> [2] Makefile of the control package
>>> http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/src/Makefile?revision=9513&view=markup
>>>
>>
>> I'd say as long as you write the appropriate Makefile, you can do
>> whatever you want.
>>
>> Michael.
>
(Continue reading)

Lukas Reichlin | 13 Feb 11:40
Picon

Re: How to combine several functions in a single oct-file? (2)


On 13.02.2012, at 10:17, Michael Goffioul wrote:

> On Mon, Feb 13, 2012 at 6:55 AM, Lukas Reichlin
> <lukas.reichlin <at> gmail.com> wrote:
>>>>>> Michael.
>>>>> 
>>>>> Hi Michael,
>>>>> 
>>>>> I like your idea of a single shared library very much. Is it possible to create such a library out of
SLICOT upon package installation? It would be nice if I could link it the same way as the BLAS and LAPACK libraries.
>>>>> 
>>>>> Best regards,
>>>>> Lukas
>>>> 
>>>> PS: I would like to include the archive slicot.tar.gz [1] in my package. Then, upon package
installation, it should be unpacked and compiled to a library I can link to. Until now, I have to add all
files by hand, which is quite ugly [2].
>>>> 
>>>> Lukas
>>>> 
>>>> [1] SLICOT Library
>>>> http://www.slicot.org/shared/slicot.tar.gz
>>>> 
>>>> [2] Makefile of the control package
>>>> http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/src/Makefile?revision=9513&view=markup
>>>> 
>>> 
>>> I'd say as long as you write the appropriate Makefile, you can do
>>> whatever you want.
(Continue reading)

Michael Goffioul | 13 Feb 11:52
Picon

Re: How to combine several functions in a single oct-file? (2)

On Mon, Feb 13, 2012 at 10:40 AM, Lukas Reichlin
<lukas.reichlin <at> gmail.com> wrote:
> Thank you very much for your explanations, Michael. I think I'll discuss the options with one of my
mentoring profs, as I am a neophyte when it comes to makefiles. What I already know: For the sake of user
friendliness, I want to keep the control package self-containing, i.e. installation by "pkg install
-forge control" without external libraries.
>
> If I create a static library (like slicotlibrary.a), will the oct-file include the entire static library
or just those parts which are needed?

AFAIK yes, only the parts needed.

> Is this related to the "code stripping" option?

No, code stripping is to remove debug symbols from the object files /
executables.

Michael.

Gmane