Next: Hashing Functions, Previous: Group Database Functions, Up: System Utilities [Contents][Index]

### 36.11 System Information

: computer () ¶
: comp = computer () ¶
: [comp, maxsize] = computer () ¶
: [comp, maxsize, endian] = computer () ¶
: arch = computer ("arch") ¶

  Print or return a string of the form cpu-vendor-os that identifies the type of computer that Octave is running on.

  If invoked with an output argument, the value is returned instead of printed. For example:

      computer ()
         -| x86_64-pc-linux-gnu

      mycomp = computer ()
         ⇒ mycomp = x86_64-pc-linux-gnu

  If two output arguments are requested, also return the maximum number of elements for an array. This will depend on whether Octave has been compiled with 32-bit or 64-bit index vectors.

  If three output arguments are requested, also return the byte order of the current system as a character (`"B"` for big-endian or `"L"` for little-endian).

  If the argument `"arch"` is specified, return a string indicating the architecture of the computer on which Octave is running.

  Results may be different if Octave was invoked with the –traditional option.

  See also: isunix, ismac, ispc.

: [uts, err, msg] = uname () ¶

  Return system information in the structure.

  For example:

      uname ()
         ⇒ {
               sysname = x86_64
               nodename = segfault
               release = 2.6.15-1-amd64-k8-smp
               version = Linux
               machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006
            }

  If successful, err is 0 and msg is an empty string. Otherwise, err is nonzero and msg contains a system-dependent error message.

: nproc () ¶
: nproc (query) ¶

  Return the current number of available processors.

  If called with the optional argument query, modify how processors are counted as follows:

  `all`

    total number of processors.

  `current`

    processors available to the current process.

  `overridable`

    same as `current`, but overridable through the `OMP_NUM_THREADS` environment variable.

: ispc () ¶

  Return true if Octave is running on a Windows system and false otherwise.

  See also: isunix, ismac.

: isunix () ¶

  Return true if Octave is running on a Unix-like system and false otherwise.

  See also: ismac, ispc.

: ismac () ¶

  Return true if Octave is running on a Mac OS X system and false otherwise.

  See also: isunix, ispc.

: isieee () ¶

  Return true if your computer claims to conform to the IEEE standard for floating point calculations.

  No actual tests are performed.

: isdeployed () ¶

  Return true if the current program has been compiled and is running separately from the Octave interpreter and false if it is running in the Octave interpreter.

  Currently, this function always returns false in Octave.

: isstudent () ¶

  Return true if running in the student edition of MATLAB.

  `isstudent` always returns false in Octave.

  See also: false.

: OCTAVE_HOME () ¶

  Return the name of the top-level Octave installation directory. OCTAVE_HOME corresponds to the configuration variable prefix.

  See also: EXEC_PATH, IMAGE_PATH, OCTAVE_EXEC_HOME.

: OCTAVE_EXEC_HOME () ¶

  Return the name of the top-level Octave installation directory for architecture-dependent files. If not specified separately, the value is the same as OCTAVE_HOME. OCTAVE_EXEC_HOME corresponds to the configuration variable exec_prefix.

  See also: EXEC_PATH, IMAGE_PATH, OCTAVE_HOME.

: matlabroot () ¶

  Return the name of the top-level Octave installation directory.

  This is an alias for the function `OCTAVE_HOME` provided for compatibility.

  See also: OCTAVE_HOME.

: cfg_dir = user_config_dir () ¶

  Return the (platform-specific) directory for user configuration.

  See also: user_data_dir.

: data_dir = user_data_dir () ¶

  Return the (platform-specific) directory for user data.

  See also: user_config_dir.

: OCTAVE_VERSION () ¶

  Return the version number of Octave as a string.

  See also: ver, version.

: v = version () ¶
: [v, d] = version () ¶
: v = version (feature) ¶

  Get version information for Octave.

  If called without input argument, the first return value v gives the version number of Octave as a string. The second return value d holds the release date as a string.

  The following options can be passed for feature:

  `"-date"`

    for the release date of the running build,

  `"-description"`

    for a description of the release (always an empty string),

  `"-release"`

    for the name of the running build (always an empty string),

  `"-java"`

    for version information of the Java VM,

  `"-fftw"`

    for version information for the linked FFTW,

  `"-blas"`

    for version information for the linked BLAS,

  `"-lapack"`

    for version information for the linked LAPACK.

  `"-hgid"`

    the mercurial ID of the sources used to build Octave.

  The information returned for the `"-blas"` and `"-lapack"` options might be unreliable. It might report which library was linked in when Octave was built instead of which library is currently used.

  The variant with no input and output argument is an alias for the function `OCTAVE_VERSION` provided for compatibility.

  See also: OCTAVE_VERSION, ver.

: ver ¶
: ver Octave ¶
: ver package ¶
: v = ver (…) ¶

  Display a header containing the current Octave version number, license string, and operating system. The header is followed by a list of installed packages, versions, and installation directories.

  Use the package name package or Octave to query a specific component.

  When called with an output argument, return a vector of structures describing Octave and each installed package. Each structure includes the following fields.

  `Name`

    Package name.

  `Version`

    Version of the package.

  `Release`

    Release of the package (currently unused, defaults to `[]`).

  `Date`

    Date that the version was released.

  See also: version, usejava, pkg.

: compare_versions (v1, v2, operator) ¶

  Compare two version strings using the given operator.

  This function assumes that versions v1 and v2 are arbitrarily long strings made of numeric and period characters possibly followed by an arbitrary string (e.g., `"1.2.3"`, `"0.3"`, `"0.1.2+"`, or `"1.2.3.4-test1"`).

  The version is first split into numeric and character portions and then the parts are padded to be the same length (i.e., `"1.1"` would be padded to be `"1.1.0"` when being compared with `"1.1.1"`, and separately, the character parts of the strings are padded with nulls).

  The operator can be any logical operator from the set

  - `"=="` equal
  - `"<"` less than
  - `"<="` less than or equal to
  - `">"` greater than
  - `">="` greater than or equal to
  - `"!="`, `"~="` not equal

  Note that version `"1.1-test2"` will compare as greater than `"1.1-test10"`. Also, since the numeric part is compared first, `"a"` compares less than `"1a"` because the second string starts with a numeric part even though `double ("a")` is greater than `double ("1").`

: verLessThan (package, version) ¶

  Return true if the installed version of the package is less than version.

  package is the name of the package to check. Use `"Octave"` as the package to check the version of Octave itself.

  version is the version to compare it to. A version is a string in the format accepted by `compare_versions`: an arbitrarily long string composed of numeric and period characters, possibly followed by an arbitrary string (e.g., `"1.2.3"`, `"0.3"`, `"0.1.2+"`, or `"1.2.3.4-test1"`).

  Examples:

      tf = verLessThan ("Octave", "5")
      ⇒ tf = 0

      tf = verLessThan ("io", "2.4.12")
      ⇒ ...

      if (! verLessThan ("Octave", "5"))
        ## ... use new Octave 5 features ...
      endif

  See also: compare_versions, version, ver, pkg.

: license ¶
: license inuse ¶
: license inuse feature ¶
: license ("inuse") ¶
: retval = license ("inuse") ¶
: retval = license ("test", feature) ¶
: retval = license ("checkout", feature) ¶
: [retval, errmsg] = license ("checkout", feature) ¶

  Get license information for Octave and Octave packages.

  GNU Octave is free software distributed under the GNU General Public License (GPL), and a license manager makes no sense. This function is provided only for MATLAB compatibility.

  When called with no extra input arguments, it returns the Octave license, otherwise the first input defines the operation mode and must be one of the following strings: `inuse`, `test`, and `checkout`. The optional feature argument can either be `"octave"` (core), or an Octave package.

  `"inuse"`

    Returns a list of loaded features, i.e., octave and the list of loaded packages. If an output is requested, it returns a struct array with the fields `"feature"`, and `"user"`.

  `"test"`

    Return true if the specified feature is installed, false otherwise.

    An optional third argument `"enable"` or `"disable"` is accepted but ignored.

  `"checkout"`

    Return true if the specified feature is installed, false otherwise. An optional second output will have an error message if a package is not installed.

  See also: pkg, ver, version.

: memory () ¶
: [userdata, systemdata] = memory () ¶

  Display or return information about the memory usage of Octave.

  If the function is called without output arguments, a table with an overview of the current memory consumption is displayed.

  The output argument userdata is a structure with the following fields containing data for the Octave process:

  `MaxPossibleArrayBytes`

    Maximum size for an array to be allocated. Be aware that this includes all physical memory and swap space. Allocating that amount of memory might result in system instability, data corruption, and/or file system corruption. Note that depending on the platform (32-bit systems), the largest contiguous memory block might further limit the maximum possible allocatable array. This check is not currently implemented.

  `MemAvailableAllArrays`

    The total size of available memory in bytes.

  `ram_available_all_arrays`

    The maximum size for an array that can be allocated in physical memory (excluding swap space). Note that depending on the platform (32-bit systems), the largest contiguous memory block might further limit the maximum possible allocatable array. This check is not currently implemented.

  `MemUsedMATLAB`
  `mem_used_octave`

    The memory (including swap space) currently used by Octave in bytes.

  `ram_used_octave`

    The physical memory (excluding swap space) currently used by Octave in bytes.

  The output argument systemdata is a nested structure with the following fields containing information about the system’s memory:

  `PhysicalMemory.Available`

    The currently available physical memory in bytes.

  `PhysicalMemory.Total`

    The total physical memory in bytes.

  `SystemMemory.Available`

    The currently available memory (including swap space) in bytes.

  `SystemMemory.Total`

    The total memory (including swap space) in bytes.

  `VirtualAddressSpace.Available`

    The currently available virtual address space in bytes.

  `VirtualAddressSpace.Total`

    The total virtual address space in bytes.

  Example #1 : print formatted table of memory usage

      memory ()
      ⇒
      System    RAM: 3934008 KiB,  swap: 4087804 KiB
      Octave    RAM:  170596 KiB,  virt: 1347944 KiB
      Free      RAM: 1954940 KiB,  swap: 4087804 KiB
      Available RAM: 2451948 KiB, total: 6042744 KiB

  Example #2 : return structs with memory usage information

      [userdata, systemdata] = memory ()
      ⇒
       userdata =

         scalar structure containing the fields:

           MaxPossibleArrayBytes = 6.1622e+09
           MemAvailableAllArrays = 6.1622e+09
           ram_available_all_arrays = 2.4883e+09
           MemUsedMATLAB = 1.3825e+09
           mem_used_octave = 1.3825e+09
           ram_used_octave = 1.7824e+08

       systemdata =

         scalar structure containing the fields:

           PhysicalMemory =

             scalar structure containing the fields:

               Available = 2.4954e+09
               Total = 4.0284e+09

           SystemMemory =

             scalar structure containing the fields:

               Available = 6.6813e+09
               Total = 8.2143e+09

           VirtualAddressSpace =

             scalar structure containing the fields:

               Available = 2.8147e+14
               Total = 2.8147e+14

  Programming Note: This function is implemented for Linux and Windows only.

  See also: computer, getpid, getrusage, nproc, uname.

: getrusage () ¶

  Return a structure containing a number of statistics about the current Octave process.

  Not all fields are available on all systems. If it is not possible to get CPU time statistics, the CPU time slots are set to zero. Other missing data are replaced by NaN. The list of possible fields is:

  `idrss`

    Unshared data size.

  `inblock`

    Number of block input operations.

  `isrss`

    Unshared stack size.

  `ixrss`

    Shared memory size.

  `majflt`

    Number of major page faults.

  `maxrss`

    Maximum data size.

  `minflt`

    Number of minor page faults.

  `msgrcv`

    Number of messages received.

  `msgsnd`

    Number of messages sent.

  `nivcsw`

    Number of involuntary context switches.

  `nsignals`

    Number of signals received.

  `nswap`

    Number of swaps.

  `nvcsw`

    Number of voluntary context switches.

  `oublock`

    Number of block output operations.

  `stime`

    A structure containing the system CPU time used. The structure has the elements `sec` (seconds) `usec` (microseconds).

  `utime`

    A structure containing the user CPU time used. The structure has the elements `sec` (seconds) `usec` (microseconds).

: value = winqueryreg (rootkey, subkey, valuename) ¶
: value = winqueryreg (rootkey, subkey) ¶
: names = winqueryreg (`"name"`, rootkey, subkey) ¶

  Query names or value from the Windows registry.

  On Windows, return the value of the registry key subkey from the root key rootkey. You can specify the name of the queried registry value with the optional argument valuename. Otherwise, if called with only two arguments or valuename is empty, then the default value of subkey is returned. If the registry value is of type `"REG_DWORD"` then value is of class int32. If the value is of the type `"REG_SZ"` or `"REG_EXPAND_SZ"` a string is returned.

  If the first argument is `"name"`, a cell array of strings with the names of the values at that key is returned.

  The variable rootkey must be a string with a valid root key identifier:

  HKCR
  HKEY_CLASSES_ROOT
  HKEY_CURRENT_CONFIG
  HKCU
  HKEY_CURRENT_USER
  HKLM
  HKEY_LOCAL_MACHINE
  HKU
  HKEY_USERS
  HKEY_PERFORMANCE_DATA

  Examples:

  Get a list of value names at the key `'HKCU\Environment'`:

      valuenames = winqueryreg ("name", "HKEY_CURRENT_USER", ...
                                "Environment");

  For each valuenames, display the value:

      for k = 1:numel (valuenames)
        val = winqueryreg ("HKEY_CURRENT_USER", "Environment", ...
                           valuenames{k});
        str = sprintf ("%s = %s", valuenames{k}, num2str (val));
        disp (str);
      endfor

  On non-Windows platforms this function fails with an error.

Next: Hashing Functions, Previous: Group Database Functions, Up: System Utilities [Contents][Index]