mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add toeplitz function
This commit is contained in:
parent
dec3de87f6
commit
71559f3e24
@ -1,34 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\webmap">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\array">
|
||||||
<RecentFolder Folder="D:\Temp\test"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\signal"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\signal"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\grib\grib2_ecmwf_3.py"/>
|
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\webmap\new_tilefactory_tianditu-1.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\webmap\new_tilefactory_tianditu-1.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\webmap\air_path.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\linalg\toeplitz_1.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\grib\grib2_ecmwf_3.py"/>
|
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\webmap\new_tilefactory_tianditu-1.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\map\webmap\new_tilefactory_tianditu-1.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\webmap\air_path.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\linalg\toeplitz_1.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
|
|||||||
@ -765,7 +765,7 @@ class NDArray(object):
|
|||||||
else:
|
else:
|
||||||
ArrayMath.setImage(self._array, val)
|
ArrayMath.setImage(self._array, val)
|
||||||
|
|
||||||
def conj(self):
|
def conjugate(self):
|
||||||
"""
|
"""
|
||||||
Return the complex conjugate, element-wise.
|
Return the complex conjugate, element-wise.
|
||||||
|
|
||||||
@ -775,6 +775,8 @@ class NDArray(object):
|
|||||||
"""
|
"""
|
||||||
return self.array_wrap(ArrayMath.conj(self._array))
|
return self.array_wrap(ArrayMath.conj(self._array))
|
||||||
|
|
||||||
|
conj = conjugate
|
||||||
|
|
||||||
def min(self, axis=None):
|
def min(self, axis=None):
|
||||||
"""
|
"""
|
||||||
Get minimum value along an axis.
|
Get minimum value along an axis.
|
||||||
|
|||||||
Binary file not shown.
@ -1 +1,6 @@
|
|||||||
from .linalg import *
|
from .linalg import *
|
||||||
|
from ._special_matrices import *
|
||||||
|
|
||||||
|
__all__ = []
|
||||||
|
__all__ += linalg.__all__
|
||||||
|
__all__ += _special_matrices.__all__
|
||||||
|
|||||||
@ -0,0 +1,76 @@
|
|||||||
|
from org.meteoinfo.ndarray.math import ArrayUtil
|
||||||
|
|
||||||
|
from .. import core as np
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ['toeplitz']
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# matrix construction functions
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def toeplitz(c, r=None):
|
||||||
|
r"""
|
||||||
|
Construct a Toeplitz matrix.
|
||||||
|
|
||||||
|
The Toeplitz matrix has constant diagonals, with c as its first column
|
||||||
|
and r as its first row. If r is not given, ``r == conjugate(c)`` is
|
||||||
|
assumed.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
c : array_like
|
||||||
|
First column of the matrix.
|
||||||
|
r : array_like, optional
|
||||||
|
First row of the matrix. If None, ``r = conjugate(c)`` is assumed;
|
||||||
|
in this case, if c[0] is real, the result is a Hermitian matrix.
|
||||||
|
r[0] is ignored; the first row of the returned matrix is
|
||||||
|
``[c[0], r[1:]]``.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
Beginning in SciPy 1.17, multidimensional input will be treated as a batch,
|
||||||
|
not ``ravel``\ ed. To preserve the existing behavior, ``ravel`` arguments
|
||||||
|
before passing them to `toeplitz`.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
A : (len(c), len(r)) ndarray
|
||||||
|
The Toeplitz matrix. Dtype is the same as ``(c[0] + r[0]).dtype``.
|
||||||
|
|
||||||
|
See Also
|
||||||
|
--------
|
||||||
|
circulant : circulant matrix
|
||||||
|
hankel : Hankel matrix
|
||||||
|
solve_toeplitz : Solve a Toeplitz system.
|
||||||
|
|
||||||
|
Notes
|
||||||
|
-----
|
||||||
|
The behavior when `c` or `r` is a scalar, or when `c` is complex and
|
||||||
|
`r` is None, was changed in version 0.8.0. The behavior in previous
|
||||||
|
versions was undocumented and is no longer supported.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
>>> from scipy.linalg import toeplitz
|
||||||
|
>>> toeplitz([1,2,3], [1,4,5,6])
|
||||||
|
array([[1, 4, 5, 6],
|
||||||
|
[2, 1, 4, 5],
|
||||||
|
[3, 2, 1, 4]])
|
||||||
|
>>> toeplitz([1.0, 2+3j, 4-1j])
|
||||||
|
array([[ 1.+0.j, 2.-3.j, 4.+1.j],
|
||||||
|
[ 2.+3.j, 1.+0.j, 2.-3.j],
|
||||||
|
[ 4.-1.j, 2.+3.j, 1.+0.j]])
|
||||||
|
|
||||||
|
"""
|
||||||
|
c = np.asarray(c)
|
||||||
|
if r is None:
|
||||||
|
r = c.conjugate()
|
||||||
|
else:
|
||||||
|
r = np.asarray(r)
|
||||||
|
|
||||||
|
ta = ArrayUtil.toeplitz(c._array, r._array)
|
||||||
|
|
||||||
|
return np.NDArray(ta)
|
||||||
@ -1426,6 +1426,31 @@ public class ArrayUtil {
|
|||||||
return Array.factory(DataType.INT, new int[]{n, n}, M);
|
return Array.factory(DataType.INT, new int[]{n, n}, M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Toeplitz matrix in which each descending diagonal
|
||||||
|
* from left to right is constant.
|
||||||
|
*
|
||||||
|
* @param col First column of the matrix. {@code A[i, j] = kl[i - j]} for {@code i > j}
|
||||||
|
* @param row First row of the matrix. {@code A[i, j] = ku[j - i]} for {@code i <= j}
|
||||||
|
* @return the Toeplitz matrix.
|
||||||
|
*/
|
||||||
|
public static Array toeplitz(Array col, Array row) {
|
||||||
|
int nx = (int) row.getSize();
|
||||||
|
int ny = (int) col.getSize();
|
||||||
|
DataType dataType = ArrayMath.commonType(col.getDataType(), row.getDataType());
|
||||||
|
Array r = Array.factory(dataType, new int[]{ny, nx});
|
||||||
|
for (int i = 0; i < ny; i++) {
|
||||||
|
for (int j = 0; j < i; j++) {
|
||||||
|
r.setObject(i * nx + j, col.getObject(i - j));
|
||||||
|
}
|
||||||
|
for (int j = i; j < nx; j++) {
|
||||||
|
r.setObject(i * nx + j, row.getObject(j - i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repeat a value n times
|
* Repeat a value n times
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user