How to know what packages I already have downloaded in Octave? - octave

I just installed Octave a few days ago and think I have been installing packages using the "pkg load name" function but never get a confirmation or anything that looks like the software is trying to download them. I also tried pkg install -forge package_name but that doesn't seem to work. Is there a difference between the two calls?
And; How can I know they are downloading? And where can I find a list of them that are?

The download function and automatic package installation in octave 4.2.1 is broken under windows. Nevertheless the standard packets come with the base installation. Just type
pkg list
in the octave console to display all installed packages. In my case the resulting list starts with these lines
Package Name | Version | Installation directory
---------------------+---------+-----------------------
communications | 1.2.1 | C:\Octave\OCTAVE~1.1\share\octave\packages\communications-1.2.1
control | 3.0.0 | C:\Octave\OCTAVE~1.1\share\octave\packages\control-3.0.0
data-smoothing | 1.3.0 | C:\Octave\OCTAVE~1.1\share\octave\packages\data-smoothing-1.3.0
database | 2.4.2 | C:\Octave\OCTAVE~1.1\share\octave\packages\database-2.4.2
dataframe | 1.1.0 | C:\Octave\OCTAVE~1.1\share\octave\packages\dataframe-1.1.0
...
To get package information programmatically use
[dummy,info]=pkg('list');
info is a cell array of structures containing information about the packages. You can e.g. read the information about name and load state:
>> info{1}.name
ans = signal
>> info{1}.loaded
ans = 0
To get help about the package function enter help pgk on the command line. This help is currently (Octave 5.1) not included in the html documentation. That means doc help does NOT display this help page.
octave windows

Related

error: tf' function belongs to the control package from Octave Forge which you have installed but not loaded

i'm doing a program in octave in which i got
t=0:.0002:20;
Gs=tf(100,[1 10])
u1=sin(t);
y1=lsim(Gs,u1,t);
plot(t,9.95*sin(t-0.1),’r’,t,y1,’b’)
However when i write Gs=tf(100,[1 10]) in the command window it appears "warning: the 'tf' function belongs to the control package from Octave Forge which
you have installed but not loaded. To load the package, run 'pkg load
control' from the Octave prompt."
How can i load this package? I trully can't understand it...
enter image description here
enter image description here
When i load it it appears:
pkg load control
warning: addpath: C:\Octave\OCTAVE~1.0\mingw64\share\octave\packages\control-3.2.0: No such file or d
irectory
warning: called from
load_packages_and_dependencies at line 48 column 5
load_packages at line 47 column 3
pkg at line 461 column 7
t=0:.0002:20;
Gs=tf(100,[1 10])
error: could not find any INDEX file in directory C:\Octave\OCTAVE~1.0\mingw64\share\octave\packages
control-3.2.0, try 'pkg rebuild all' to generate missing INDEX files
error: called from
describe>parse_pkg_idx at line 94 column 5
describe at line 59 column 40
pkg at line 555 column 43
unimplemented>check_package at line 540 column 15
unimplemented at line 127 column 11
In the octave terminal, type
pkg load control
To load the control package. If you do not already have the control package installed, you need to install it. You can do so directly from Octave Forge by typing
pkg install -forge control
Note that this will install this package in your predefined 'prefix'. You can find where that is by typing
pkg prefix
If you're not sure if you have the control package installed, you can check the list of already installed packages by typing
pkg list
Type help pkg to see more details about how octave's package manager works.
In any case, the tf function belongs to the control package, and like all packages, you need to load it before you can use its functions.
Having said this, even after loading the control package, your above code doesn't work. It seems like you're calling the tf function using the wrong format.

unable to install any pkg in Octave

I am new to Octave, coming from Matlab. I am trying to install a few packages, and so far none has worked. I have tried the download method from forge, then running the install command. But my question is about my latest attempt. There it is:
pkg install -global -forge io
csvconcat.cc:79:37: warning: result of comparison of constant 18446744073709551615 with expression of type
'unsigned int' is always true [-Wtautological-constant-out-of-range-compare]
while ((pos=str.find(prot, pos)) != str.npos) {
~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~
1 warning generated.
error: couldn't append to /Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/octave-octave-app#4.4.1/4.4.1/share/octave/octave_packages
save: unable to open output file '/Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/octave-octave-app#4.4.1/4.4.1/share/octave/octave_packages'
error: called from
install at line 254 column 7
pkg at line 437 column 9
Couldn't find any documentation on it, I am a bit lost.... (oh and btw, I can't find the config.log file! where is that gem?)
I am on MacOS catalina 10.15.7, and just followed that procedure https://flaviocopes.com/fix-xcrun-error-invalid-active-developer-path/, which solved the issues I had before which is described on that page.
cheers for any help
The error:
error: couldn't append to /Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/octave-octave-app#4.4.1/4.4.1/share/octave/octave_packages
save: unable to open output file '/Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/octave-octave-app#4.4.1/4.4.1/share/octave/octave_packages'
error: called from
install at line 254 column 7
pkg at line 437 column 9
basically says it's failing to save to that file. Probably a permissions issue. Check if the file /Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/octave-octave-app#4.4.1/4.4.1/share/octave/octave_packages exists and its permissions. That file is a database of all packages installed globally, i.e., for all users in the system.
Fixing the permission issues is dependent on what is the permissions issue you have (probably you need to run octave as root to install a global package). But maybe try to install the package for your user only, i.e., install the package without the -global flag, like so:
pkg install -forge io

Octave: Parse output of command

Generally, I would like to be able to parse output of Octave commands such as pkg list image. Unfortunately, I cannot assign the output to a string, such as s = pkg list image.
I know that it's not absolutely necessary to be able to do this, because the error message when doint pkg load thispackagedoesnotexist is clear enough, but I'd still like to know whether it's possible, and if yes, how.
You should not need to parse the printed output of Octave functions. Octave functions return values, and it's much simpler and obvious to check those values instead.
In your specific case, you only want to check if a package is installed. So just check if the package appears listed in pkg:
installed = cellfun (#(x) x.name, pkg ("list"),
"UniformOutput", false);
if (! any (strcmp (installed, "foo")))
# Package foo is not installed
endif
or check if its description is empty:
if (isempty (pkg ("describe", "foo"){1}))
# Package foo is not installed
endif
Use system command launching another copy of octave:
[output,text]=system("echo 'pkg list image' |octave -q 2>/dev/null",true);
output is:
output = 0
text = Package Name | Version | Installation directory
----------------+---------+-----------------------
data-smoothing *| 1.3.0 | /usr/share/octave/packages/data-smoothing-1.3.0
dataframe | 0.9.1 | /usr/share/octave/packages/dataframe-0.9.1
general *| 1.3.4 | /usr/share/octave/packages/general-1.3.4
io *| 2.0.2 | /usr/share/octave/packages/io-2.0.2
linear-algebra *| 2.2.0 | /usr/share/octave/packages/linear-algebra-2.2.0
miscellaneous *| 1.2.0 | /usr/share/octave/packages/miscellaneous-1.2.0
nnet *| 0.1.13 | /usr/share/octave/packages/nnet-0.1.13
odepkg *| 0.8.4 | /usr/share/octave/packages/odepkg-0.8.4
optim *| 1.3.0 | /usr/share/octave/packages/optim-1.3.0
optiminterp *| 0.3.4 | /usr/share/octave/packages/optiminterp-0.3.4
parallel *| 2.2.0 | /usr/share/octave/packages/parallel-2.2.0
plot *| 1.1.0 | /usr/share/octave/packages/plot-1.1.0
splines *| 1.2.6 | /usr/share/octave/packages/splines-1.2.6
statistics *| 1.2.3 | /usr/share/octave/packages/statistics-1.2.3
strings *| 1.1.0 | /usr/share/octave/packages/strings-1.1.0
struct *| 1.0.10 | /usr/share/octave/packages/struct-1.0.10
symbolic *| 1.1.0 | /usr/share/octave/packages/symbolic-1.1.0
Also, you can list all packages. From octave documentation:
'list'
Show the list of currently installed packages. For example,
installed_packages = pkg ("list")
returns a cell array containing a structure for each installed
package.
If two output arguments are requested 'pkg' splits the list of
installed packages into those which were installed by the
current user, and those which were installed by the system
administrator.
[user_packages, system_packages] = pkg ("list")
The option "-forge" lists packages available at the
Octave-Forge repository. This requires an internet connection
and the cURL library. For example:
oct_forge_pkgs = pkg ("list", "-forge")
It's difficult to tell what you actually want to do with the output, but it is entirely possible that the pkg function will return information into a useful variable for you if you call it the right way. I recommend you check out the help for pkg function and look at the functional form and the type of things it will return
https://www.gnu.org/software/octave/doc/interpreter/Installing-and-Removing-Packages.html
For example:
[desc, flag] = pkg ("describe", "secs1d", "image")
will return flag which will tell you the installed or loaded state of the package.

warbler seems to use a different ffi that doesn't understand size_t

FFI understands :size_t when running rails through jRuby, but not after using Warbler to create a .war file and running that using java -jar my_project.war or Tomcat.
Linux | Windows
-----------------------------+-------------
java -jar works | doesn't work
tomcat works | doesn't work
rails s (using jruby) works | works
Linux and Windows use the same war file in the comparison.
Here is the top of a backtrace from running java -jar on Windows. (I've edited the beginnings of the file paths in the backtrace).
--- Backtrace
TypeError: unable to resolve type 'size_t'
find_type at jar:file:/my_project.war/WEB-INF/lib/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/types.rb:55
type_size at jar:file:/my_project.war/WEB-INF/lib/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/types.rb:147
SQLAnywhere at my_project.war/WEB-INF/gems/gems/sqlanywhere-ffi-1.0.1/lib/sqlanywhere.rb:13
(root) at my_project.war/WEB-INF/gems/gems/sqlanywhere-ffi-1.0.1/lib/sqlanywhere.rb:5
require at org/jruby/RubyKernel.java:1027
When I look at the files in the backtrace, they list various c types, but not size_t.
It seems to me that there are 2 FFIs available to jRuby.
The normal FFI gem.
The jruby-stdlib ffi.
The big difference between the 2, seems to be that only the former understands :size_t.
My question is: Are there 2 different FFIs?
If so: how do I make sure that my gem loads the correct ffi?
If not: what am I doing wrong?
PS: I'm the author of the sqlanywhere-ffi gem, so if the problem is I'm depending on the wrong thing, I can change it. Currently it has ffi as a depenendency in the gemspec, the gemfile and it requires 'ffi' in the main entry point.
(I've edited the beginnings of the file paths in the backtrace).
I guess the full path of your Tomcat-directory contains whitespaces, make sure it doesn't.
This problem did not occur with jruby-1.6 versions.

error installing octcdf-1.1.5

I Have in my Mac:
Octave-3.4.0
Gnuplot 4.2 - that I had to install because I had problems plotting - it wouldn't plot at all.
I need to load a netcdf file, the error that came was:
nc = netcdf('/users/matheuscortezi/Desktop/Pcse005/ocean_avg.nc', 'r')
error: `netcdf' undefined near line 9 column 6
So I think I don't have the netcdf comand installed, and tried installing by typing this on octave:
pkg install -global -forge octcdf
The error message that I receive from that is:
configure: error: in `/var/tmp/oct-t8XcYD/octcdf/src':
configure: error: C compiler cannot create executables
See `config.log' for more details.
the configure script returned the following error: checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
error: called from `pkg>configure_make' in file /Applications/Octave.app/Contents/Resources/share/octave/3.4.0/m/pkg/pkg.m near line 1325, column 9
error: called from:
error: /Applications/Octave.app/Contents/Resources/share/octave/3.4.0/m/pkg/pkg.m at line 783, column 5
error: /Applications/Octave.app/Contents/Resources/share/octave/3.4.0/m/pkg/pkg.m at line 354, column 9
I haven't the faintest idea about what I should do. How can I solve this problem with either:
fixing this error, or
installing a netcdf "comand pack" (i don't know the name for that) so I can use netcdf() as in the example given.
Hope I was clear enough.
It seems to me that you installed Octave from the Mac OSX App bundle. That is not recommended at all. You should install from one of the package managers as explained on Octave's wiki. As far as I know, there are 3 options for Mac (see previous link). Just search for one that also has the netcdf package.
Anyway, if you really don't want to install it through a package manager (but seems to me you really should), seems that your problem lies on gcc (the GNU C compiler). do you have it installed at all? Some packages have code in C++ or C and are also dependent on some external libraries.
EDIT using a package manager would have also solved your problem about plotting since it would install gnuplot at same time