# cond¶

paddle.linalg. cond ( x, p=None, name=None ) [源代码]

## 参数¶

• x (Tensor)：输入可以是形状为 `(*, m, n)` 的矩阵 Tensor， `*` 为零或更大的批次维度，此时 `p`2-2；也可以是形状为 `(*, n, n)` 的可逆（批）方阵 Tensor，此时 `p` 为任意已支持的值。数据类型为 float32 或 float64 。

• p (float|string，可选)：范数种类。目前支持的值为 fronuc1-12-2inf-inf。默认值为 None，即范数种类为 2

• name (str，可选) - 具体用法请参见 Name，一般无需设置，默认值为 None。

## 返回¶

Tensor，条件数的计算结果，数据类型和输入 `x` 的一致。

## 代码示例¶

```>>> import paddle
>>> x = paddle.to_tensor([[1., 0, -1], [0, 1, 0], [1, 0, 1]])

>>> # compute conditional number when p is None
>>> print(out)
1.41421378)

>>> # compute conditional number when order of the norm is 'fro'
>>> print(out_fro)
3.16227770)

>>> # compute conditional number when order of the norm is 'nuc'
>>> print(out_nuc)
9.24264145)

>>> # compute conditional number when order of the norm is 1
>>> print(out_1)
2.)

>>> # compute conditional number when order of the norm is -1
>>> print(out_minus_1)
1.)

>>> # compute conditional number when order of the norm is 2
>>> print(out_2)
1.41421378)

>>> # compute conditional number when order of the norm is -1
>>> print(out_minus_2)
0.70710671)

>>> # compute conditional number when order of the norm is inf
>>> print(out_inf)
2.)

>>> # compute conditional number when order of the norm is -inf
>>> print(out_minus_inf)
1.)

>>> a = paddle.randn([2, 4, 4])
>>> print(a)
Tensor(shape=[2, 4, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[ 0.06132207,  1.11349595,  0.41906244, -0.24858207],
[-1.85169315, -1.50370061,  1.73954511,  0.13331604],
[ 1.66359663, -0.55764782, -0.59911072, -0.57773495],
[-1.03176904, -0.33741450, -0.29695082, -1.50258386]],
[[ 0.67233968, -1.07747352,  0.80170447, -0.06695852],
[-1.85003340, -0.23008066,  0.65083790,  0.75387722],
[ 0.61212337, -0.52664012,  0.19209868, -0.18707706],
[-0.00711021,  0.35236868, -0.40404350,  1.28656745]]])

>>> print(a_cond_fro)
[6.37173700 , 35.15114594])

>>> b = paddle.randn([2, 3, 4])
>>> print(b)
Tensor(shape=[2, 3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[ 0.03306439,  0.70149767,  0.77064633, -0.55978841],
[-0.84461296,  0.99335045, -1.23486686,  0.59551388],
[-0.63035583, -0.98797107,  0.09410731,  0.47007179]],
[[ 0.85850012, -0.98949534, -1.63086998,  1.07340240],
[-0.05492965,  1.04750168, -2.33754158,  1.16518629],
[ 0.66847134, -1.05326962, -0.05703246, -0.48190674]]])