Changeset 367
- Timestamp:
- Mar 31, 2004, 11:44:17 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r366 r367 1 %%% $Id: psLibSDRS.tex,v 1.2 7 2004-04-01 09:42:39 eugene Exp $1 %%% $Id: psLibSDRS.tex,v 1.28 2004-04-01 09:44:17 price Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 1479 1479 \end{verbatim} 1480 1480 1481 The following function populates the histogram bins from the specified 1482 array (\code{myArray}), the number of entries less than \code{minVal} 1483 (\code{minNum}), and the number of entries greater than \code{maxVal} 1484 (\code{maxNum}). It alters and returns the \code{psHistogram} 1485 structure. 1486 1487 \begin{verbatim} 1488 /** Calculate a histogram \ingroup MathGroup **/ 1489 psHistogram * 1490 psGetArrayHistogram(psHistogram *restrict myHist, ///< Histogram data 1491 const psFloatArray *restrict myArray ///< Array to analyse 1492 ); 1493 \end{verbatim} 1494 1481 1495 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1482 1496 1483 1497 \subsection{Matrix operations and linear algebra} 1484 1498 1485 We require the ability to perform basic linear algebra on matrices, in 1486 order to solve equations: 1487 1488 \begin{verbatim} 1489 /** A matrix */ 1490 typedef struct { 1491 int xSize, ySize; ///< Dimensions in x and y 1492 float *restrict *restrict value; ///< Values in matrix 1493 } psMatrix; 1494 \end{verbatim} 1495 1496 Constructor and destructor are: 1497 1498 \begin{verbatim} 1499 /** Constructor */ 1500 psMatrix * 1501 psMatrixAlloc(int Xdimen, ///< x dimension of new matrix 1502 int Ydimen ///< y dimension of new matrix 1503 ); 1504 \end{verbatim} 1505 1506 \begin{verbatim} 1507 /** Destructor */ 1508 void 1509 psMatrixFree(psMatrix *restrict myMatrix ///< Matrix to destroy 1510 ); 1511 \end{verbatim} 1512 1513 We require the following basic matrix operations: 1499 In addition to the ability to perform image arithmetic (\S\ref{sec:arithmetic}), 1500 we also require the ability to perform basic linear algebra on matrices, in order 1501 to solve equations. We use \code{psImage} as a matrix, since it has the correct 1502 form, and we define the following basic matrix operations: 1514 1503 \begin{itemize} 1504 \item $LU$ Decompose a matrix, and solve for $x$ in $Ax = b$; 1515 1505 \item Invert a matrix; 1516 1506 \item Calculate a matrix determinant; … … 1519 1509 \item Convert a matrix to a vector. 1520 1510 \end{itemize} 1521 The corresponding APIs are: 1511 The corresponding APIs follow. 1512 1513 \begin{verbatim} 1514 /** LU Decomposition of a matrix */ 1515 psImage * 1516 psMatrixLUD(psImage *out, ///< Matrix to return, or NULL 1517 psImage *myMatrix ///< Matrix to decompose 1518 ); 1519 1520 /** LU Solution. Solves for and returns x in the equation Ax = b */ 1521 psVector * 1522 psMatrixLUSolve(psVector *out, ///< Vector to return, or NULL 1523 const psImage *luMatrix, ///< LU-decomposed matrix 1524 const psVector *rhsVector ///< right-hand-side of the equation 1525 ); 1526 \end{verbatim} 1527 1528 The above functions decompose a matrix, \code{myMatrix}, into its $LU$ 1529 representation (\code{psMatrixLUD}, which returns the decomposed 1530 matrix), and uses the decomposed matrix to solve for $x$ in the 1531 equation $Ax = b$. In this case, the $LU$ decomposed matrix $A$ is 1532 specified as \code{luMatrix}, and $b$ is \code{rhsVector}; the 1533 solution for $x$ is returned. 1522 1534 1523 1535 \begin{verbatim} … … 1530 1542 \end{verbatim} 1531 1543 1544 \code{psMatrixInvert} returns the inverse of the specified matrix 1545 (\code{myMatrix}), along with the \code{determinant}, if non-NULL. 1546 1547 The matrix determinant may be calculated using 1548 \code{psMatrixDeterminant}, which simply returns the determinant for 1549 the specified matrix, \code{myMatrix}. 1550 1532 1551 \begin{verbatim} 1533 1552 /** Matrix determinant */ … … 1536 1555 ); 1537 1556 \end{verbatim} 1557 1558 Matrix arithmetic is supported through \code{psMatrixOp}. Note that 1559 \code{psMatrixOp} differs from \code{psBinaryOp} in that 1560 multiplication with \code{psBinaryOp} acts on corresponding elements, 1561 while \code{psMatrixOp} performs classical matrix multiplication 1562 involving row and column operations. Addition and subtraction by 1563 \code{psMatrixOp} are identical to that for \code{psBinaryOp} (since 1564 that is how matrix addition is defined). Matrix division is not 1565 defined. 1538 1566 1539 1567 \begin{verbatim} … … 1547 1575 \end{verbatim} 1548 1576 1577 The transpose of an input matrix, \code{myMatrix}, is returned by 1578 \code{psMatrixTranspose}. 1579 1549 1580 \begin{verbatim} 1550 1581 /** Transpose Matrix */ … … 1555 1586 \end{verbatim} 1556 1587 1588 Finally, we specify two functions to convert between matrices and 1589 vectors. This allows the use of vectors in matrix arithmetic, since 1590 a vector can be converted to a matrix, utilised, and the result can 1591 be converted back to a vector if required. 1592 1557 1593 \begin{verbatim} 1558 1594 /** Convert matrix to vector. Intended for a 1-d matrix. */ … … 1568 1604 \end{verbatim} 1569 1605 1570 Note that \code{psMatrixOp} differs from \code{psBinaryOp} in that1571 \code{psBinaryOp} acts on each element independently, while1572 \code{psMatrixOp} performs classical matrix arithmetic, involving row1573 and column operations.1574 1606 1575 1607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 1594 1626 \end{verbatim} 1595 1627 1596 The \code{p_psFFTDetails *details} entry allows us to wrap the 1597 external library in the event that it carries information around from 1598 one transform to the next (as is the case for FFTW). The intent is 1599 that every function that employs a FFT will act on a \code{psFFT}. A 1600 user will create a \code{psFFT} by stuffing it with the real data, 1601 perform operations in Fourier space using the \code{psFFT}, and then 1602 extract the output as an image when done. 1628 The \code{*details} entry allows us to wrap the external library in 1629 the event that it carries information around from one transform to the 1630 next (as is the case for FFTW), and hence it is 1631 implementation-dependent. The intent is that every function that 1632 employs a FFT will act on a \code{psFFT}. A user will create a 1633 \code{psFFT} by stuffing it with the real data, perform operations in 1634 Fourier space using the \code{psFFT}, and then extract the output as 1635 an image when done. 1603 1636 1604 1637 We specify two constructors --- one for use with images, and the other … … 1624 1657 \end{verbatim} 1625 1658 1626 The forward and reverse Fourier transforms may be calculated: 1659 The forward and reverse Fourier transforms may be calculated, 1660 returning the altered \code{psFFT}: 1627 1661 1628 1662 \begin{verbatim} … … 1639 1673 1640 1674 The data in Fourier space may be filtered using functions that return 1641 a multiplicative factor for a given position in Fourier space: 1675 a multiplicative factor for a given position in Fourier space. These 1676 function return the altered \code{psFFT}. If the filter function 1677 specified for \code{psFFTFilter()} returns a real value, $r$, then the 1678 corresponding value in the Fourier plane should be multiplied by $r$. 1679 If the real and imaginary filter functions specified for 1680 \code{psFFTFilterComplex()} return the values $r$ and $s$, 1681 respectively, then the corresponding value in the Fourier plane should 1682 be multiplied by the complex number $r + si$. 1642 1683 1643 1684 \begin{verbatim} … … 1667 1708 \end{verbatim} 1668 1709 1669 The power spectrum is calculated from the Fourier transform: 1710 The power spectrum is calculated from the Fourier transform, returning 1711 an array of floating-point values containing the power spectrum. 1670 1712 1671 1713 \begin{verbatim} … … 1676 1718 \end{verbatim} 1677 1719 1678 In convolution, two Fourier transforms are multiplied. 1720 In convolution, two Fourier transforms are multiplied, and the resultant 1721 \code{psFFT} is returned. 1679 1722 1680 1723 \begin{verbatim} … … 1687 1730 1688 1731 And finally, the user may extract both the real data and the complex 1689 Fourier space data (without needing to destroy the \code{psFFT}). 1732 Fourier space data as \code{psImage}s (without needing to destroy the 1733 \code{psFFT}). For \code{psFFTGetFT}, note that the output image will be of 1734 type \code{complex float}, since it extracts the data in the Fourier plane, 1735 which is complex. 1690 1736 1691 1737 \begin{verbatim} … … 1783 1829 \end{verbatim} 1784 1830 1785 And the polynomials may be evaluated: 1831 And the polynomials may be evaluated, returning the value of the 1832 polynomial at the specified coordinates: 1786 1833 1787 1834 \begin{verbatim} … … 1794 1841 \end{verbatim} 1795 1842 1796 \tbd{ generate a Gaussian deviate vector}1843 \tbd{Generate a Gaussian deviate vector} 1797 1844 1798 1845 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 1802 1849 We require a general minimization routine, a routine that will 1803 1850 specifically minimize $\chi^2$ given a list of data with associated 1804 errors, and a function that will analytically determine the polynomial1805 fit by least-squares. The APIs are:1851 errors, and a function that will analytically determine the best 1852 polynomial fit by minimizing $\chi^2$. The APIs are: 1806 1853 1807 1854 \begin{verbatim} … … 1812 1859 ); 1813 1860 \end{verbatim} 1861 1862 \code{psMinimize} determines and returns the parameters that minimizes 1863 the specified function. It takes as input a function, 1864 \code{myFunction}, an initial guess for the parameters that minimize 1865 the function, \code{initialGuess}, and an optional mask for the 1866 parameters to minimize, \code{paramMask}. 1814 1867 1815 1868 \begin{verbatim} … … 1827 1880 \end{verbatim} 1828 1881 1882 \code{psMinimizeChi2} fits a model to observations by minimizing 1883 $\chi^2$, returing the best-fit parameters. The input parameters are 1884 a function that evaluates the model for a specified domain, given the 1885 parameters, \code{evalModel}; a list of observations, (\code{domain}, 1886 \code{data}, and \code{errors}); an initial guess at the best-fit 1887 parameters, \code{initialGuess}, and an optional mask specifying which 1888 parameters are to be fit, \code{paramMask}. 1889 1829 1890 \begin{verbatim} 1830 1891 /** Derive a polynomial that goes through the points --- can be done analytically */ … … 1834 1895 ); 1835 1896 \end{verbatim} 1897 1898 \code{psGetArrayPolynomial} calculates analytically and returns the 1899 polynomial that best fits the observations. The input parameters are 1900 a polynomial that specifies the fit order, \code{myPoly}, which will 1901 be altered and returned with the best-fit coefficients; and the 1902 observations, \code{x}, \code{y} and \code{yErr}. 1903 1904 \TBD{Higher-order (primarily 2D) polynomial fits may also be specified 1905 in the future.} 1836 1906 1837 1907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 2140 2210 2141 2211 \subsection{Vector and Image Arithmetic} 2212 \label{sec:arithmetic} 2142 2213 2143 2214 We will need to be able to perform various operations on vectors and
Note:
See TracChangeset
for help on using the changeset viewer.
