# jacobian.py¶

Define the base Jacobian class.

class openmdao.jacobians.jacobian.Jacobian(system)[source]

Bases: object

Base Jacobian class.

This class provides a dictionary interface for sub-Jacobians and performs matrix-vector products when apply_linear is called.

__contains__(self, key)[source]

Return whether there is a subjac for the given promoted or relative name pair.

Parameters
key(str, str)

Promoted or relative name pair of sub-Jacobian.

Returns
boolean

return whether sub-Jacobian has been defined.

__getitem__(self, key)[source]

Get sub-Jacobian.

Parameters
key(str, str)

Promoted or relative name pair of sub-Jacobian.

Returns
ndarray or spmatrix or list[3]

sub-Jacobian as an array, sparse mtx, or AIJ/IJ list or tuple.

__init__(self, system)[source]

Initialize all attributes.

Parameters
systemSystem

Parent system to this jacobian.

__iter__(self)[source]

Yield next name pair of sub-Jacobian.

__setitem__(self, key, subjac)[source]

Set sub-Jacobian.

Parameters
key(str, str)

Promoted or relative name pair of sub-Jacobian.

subjacint or float or ndarray or sparse matrix

sub-Jacobian as a scalar, vector, array, or AIJ list or tuple.

items(self)[source]

Yield name pair and value of sub-Jacobian.

property msginfo

Return info to prepend to messages.

Returns
str

Info to prepend to messages.

set_complex_step_mode(self, active)[source]

Turn on or off complex stepping mode.

When turned on, the value in each subjac is cast as complex, and when turned off, they are returned to real values.

Parameters
activebool

Complex mode flag; set to True prior to commencing complex step.

openmdao.jacobians.jacobian.rand(d0, d1, ..., dn)

Random values in a given shape.

Note

This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.

Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

Parameters
d0, d1, …, dnint, optional

The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.

Returns
outndarray, shape (d0, d1, ..., dn)

Random values.

random
>>> np.random.rand(3,2)