Difference between revisions of "Spnull"
Jump to navigation
Jump to search
m |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 3: | Line 3: | ||
|desc=Returns a sparse orthonormal basis for the null space | |desc=Returns a sparse orthonormal basis for the null space | ||
|upd=May 10, 2010 | |upd=May 10, 2010 | ||
| − | |v= | + | |rel=[[sporth]] |
| + | |cat=[[List of functions#Helper_functions|Helper functions]] | ||
| + | |v=0.50 | ||
|lic=1 | |lic=1 | ||
|helper=1}} | |helper=1}} | ||
| Line 18: | Line 20: | ||
==Examples== | ==Examples== | ||
The following example gives a 4-by-4 matrix whose null space is spanned by the two vectors $[0,0,1,0]^T$ and $[0,0,0,1]^T$: | The following example gives a 4-by-4 matrix whose null space is spanned by the two vectors $[0,0,1,0]^T$ and $[0,0,0,1]^T$: | ||
| − | < | + | <syntaxhighlight> |
>> S = sparse(4,4); | >> S = sparse(4,4); | ||
>> S(1,1) = 1; S(3,2) = 1; | >> S(1,1) = 1; S(3,2) = 1; | ||
| Line 27: | Line 29: | ||
(3,1) 1 | (3,1) 1 | ||
(4,2) 1 | (4,2) 1 | ||
| − | </ | + | </syntaxhighlight> |
Note that the output is sparse because <tt>S</tt> is sparse. If the input is full then the output will be full as well: | Note that the output is sparse because <tt>S</tt> is sparse. If the input is full then the output will be full as well: | ||
| − | < | + | <syntaxhighlight> |
>> spnull(full(S)) | >> spnull(full(S)) | ||
| Line 39: | Line 41: | ||
1 0 | 1 0 | ||
0 1 | 0 1 | ||
| − | </ | + | </syntaxhighlight> |
| + | |||
| + | {{SourceCode|name=spnull|helper=1}} | ||
==External links== | ==External links== | ||
* [http://www.mathworks.com/matlabcentral/fileexchange/27550-sparse-null-space-and-orthogonal Sparse null space and orthogonal]: The source of this file on MATLAB File Exchange | * [http://www.mathworks.com/matlabcentral/fileexchange/27550-sparse-null-space-and-orthogonal Sparse null space and orthogonal]: The source of this file on MATLAB File Exchange | ||
Latest revision as of 16:29, 29 September 2014
| spnull | |
| Returns a sparse orthonormal basis for the null space | |
| Other toolboxes required | none |
|---|---|
| Related functions | sporth |
| Function category | Helper functions |
| License | license_spnull.txt |
| This is a helper function that only exists to aid other functions in QETLAB. If you are an end-user of QETLAB, you likely will never have a reason to use this function. |
spnull is a function that computes an orthonormal basis for the null space of a full or sparse matrix. When the matrix is sparse, this computation is performed via the QR decomposition and is typically much faster than using null(full(S)).
Syntax
- Z = spnull(S)
- Z = spnull(S,varargin)
Argument descriptions
- S: The matrix to have its null space computed.
- varargin (optional): Extra arguments that, if S is full, will be passed to MATLAB's null function.
Examples
The following example gives a 4-by-4 matrix whose null space is spanned by the two vectors $[0,0,1,0]^T$ and $[0,0,0,1]^T$:
>> S = sparse(4,4);
>> S(1,1) = 1; S(3,2) = 1;
>> spnull(S)
ans =
(3,1) 1
(4,2) 1Note that the output is sparse because S is sparse. If the input is full then the output will be full as well:
>> spnull(full(S))
ans =
0 0
0 0
1 0
0 1Source code
Click here to view this function's source code on github.
External links
- Sparse null space and orthogonal: The source of this file on MATLAB File Exchange