Main Content

pagelsqminnorm

Page-wise minimum-norm least-squares solution to linear equation

Since R2024a

    Description

    X = pagelsqminnorm(A,B) computes the minimum-norm solution of the least-squares system AX = B for each page of the N-D arrays A and B. Each page of the output array X is given by X(:,:,i) = lsqminnorm(A(:,:,i),B(:,:,i)).

    If A and B have more than three dimensions, then pagelsqminnorm implicitly expands the additional dimensions to solve the least-squares systems of all page combinations, as in X(:,:,i,j,k) = lsqminnorm(A(:,:,i,j,k),B(:,:,i,j,k)).

    example

    X = pagelsqminnorm(A,B,tol) also specifies one or more tolerances that pagelsqminnorm uses to determine the rank of each page of A.

    Examples

    collapse all

    Create a 3-by-3-by-2 array A and a 3-by-1-by-2 array B.

    A = cat(3,magic(3),hilb(3))
    A = 
    A(:,:,1) =
    
         8     1     6
         3     5     7
         4     9     2
    
    
    A(:,:,2) =
    
        1.0000    0.5000    0.3333
        0.5000    0.3333    0.2500
        0.3333    0.2500    0.2000
    
    
    B = ones(3,1,2)
    B = 
    B(:,:,1) =
    
         1
         1
         1
    
    
    B(:,:,2) =
    
         1
         1
         1
    
    

    Solve the linear system A(:,:,i)*X(:,:,i) = B(:,:,i) for each corresponding set of pages in A and B using pagelsqminnorm.

    X = pagelsqminnorm(A,B)
    X = 
    X(:,:,1) =
    
        0.0667
        0.0667
        0.0667
    
    
    X(:,:,2) =
    
        3.0000
      -24.0000
       30.0000
    
    

    Input Arguments

    collapse all

    Coefficient array, specified as a matrix or multidimensional array.

    Data Types: single | double
    Complex Number Support: Yes

    Input array, specified as a matrix or multidimensional array.

    Data Types: single | double
    Complex Number Support: Yes

    Rank tolerance, specified as a nonnegative scalar or multidimensional array of size [1 1 size(A,3:ndims(A))]. Specifying the tolerance can help the solutions be resilient against random noise in the coefficient matrix. Specify a scalar tolerance to use the same tolerance for all array pages. Specify an array of tolerances to use a different tolerance for each page.

    By default, pagelsqminnorm computes the tolerance based on the QR decomposition of each page of A.

    Example: X = pagelsqminnorm(A,B,1e-2)

    Data Types: double

    More About

    collapse all

    Array Pages

    Page-wise functions like pagelsqminnorm operate on 2-D matrices that have been arranged into a multidimensional array. For example, the elements in the third dimension of a 3-D array are commonly called pages because they stack on top of each other like pages in a book. Each page is a matrix that the function operates on.

    3-D array with several matrices stacked on top of each other as pages in the third dimension

    You can also assemble a collection of 2-D matrices into a higher dimensional array, like a 4-D or 5-D array, and in these cases pagelsqminnorm still treats the fundamental unit of the array as a 2-D matrix that the function operates on, such as X(:,:,i,j,k,l).

    The cat function is useful for assembling a collection of matrices into a multidimensional array, and the zeros function is useful for preallocating a multidimensional array.

    Tips

    • pagelsqminnorm(A,B,tol) is typically more efficient than pagemtimes(pagepinv(A,tol),B) for computing minimum-norm least-squares solutions to linear systems. pagelsqminnorm uses the complete orthogonal decomposition (COD) to find a low-rank approximation of each page of A, while pagepinv uses the singular value decomposition (SVD). Therefore, the results of pagepinv and pagelsqminnorm do not match exactly.

    • Results obtained using pagelsqminnorm are numerically equivalent to using lsqminnorm to compute the minimum-norm solution of each of the same least-squares systems in a for-loop. However, the two results might differ slightly due to floating-point round-off error.

    Extended Capabilities

    Version History

    Introduced in R2024a