# func_comp_common.py

# func_comp_common.py¶

Define functions and objects common to the ExplicitFuncComp and ImplicitFuncComp classes.

- openmdao.components.func_comp_common.jac_forward(
fun,argnums,tangents)[source]Similar to the jax.jacfwd function but allows specification of the tangent matrix.

This allows us to generate a compressed jacobian based on coloring.

- Parameters

funfunctionThe function to be differentiated.

argnumstuple of int or NoneSpecifies which positional args are dynamic. None means all positional args are dynamic.

tangentsndarrayArray of 1.0’s and 0’s that is used to compute the value of the jacobian matrix.

- Returns

- function
If there are multiple output variables, returns a function that returns rows of the jacobian grouped by output variable, e.g., if there were 2 output variables of size 3 and 4, the function would return a list with two entries. The first entry would contain the first 3 rows of J and the second would contain the next 4 rows of J. If there is only 1 output variable, the values returned are grouped by input variable.

- openmdao.components.func_comp_common.jac_reverse(
fun,argnums,tangents)[source]Similar to the jax.jacrev function but allows specification of the tangent matrix.

This allows us to generate a compressed jacobian based on coloring.

- Parameters

funfunctionThe function to be differentiated.

argnumstuple of int or NoneSpecifies which positional args are dynamic. None means all positional args are dynamic.

tangentsndarrayArray of 1.0’s and 0’s that is used to compute the value of the jacobian matrix.

- Returns

- function
A function that returns rows of the jacobian grouped by function input variable, e.g., if there were 3 input variables of size 5 and 7 and 9, the function would return a list with 3 entries. The first entry would contain the first 5 columns of J, the second the next 7 columns of J, and the third the next 9 columns of J. Note that for implicit systems, the function inputs will contain both inputs and outputs in the context of OpenMDAO.

- openmdao.components.func_comp_common.jacvec_prod(
fun,argnums,invals,tangent)[source]Similar to the jvp function but gives back a flat column.

Note: this is significantly slower (when producing a full jacobian) than jac_forward.

- Parameters

funfunctionThe function to be differentiated.

argnumstuple of int or NoneSpecifies which positional args are dynamic. None means all positional args are dynamic.

invalstuple of float or ndarrayDynamic function input values.

tangentndarrayArray of 1.0’s and 0’s that is used to compute a column of the jacobian matrix.

- Returns

- function
A function to compute the jacobian vector product.