Sun S3L 3.0 Programming and Reference Guide

Least Squares Solver

S3L_gen_lsq

Description

If m >= n, S3L_gen_lsq finds the least squares solution of an overdetermined system. That is, it solves the least squares problem:


Example 8-75

minimize || B - A*X ||

On output, the first n rows of B hold the least squares solution X.

If m < n, S3L_gen_lsq finds the minimum norm solution of an underdetermined system:


Example 8-76

A * X = B(1:m,:)

On output, B holds the minimum norm solution X.

Syntax

The C and Fortran syntax for S3L_gen_lsq are shown below.

C/C++ Syntax


Example 8-77

#include <s3l/s3l-c.h>
#include <s3l/s3l_errno-c.h>
int
S3L_gen_lsq(A, B, axis1, axis2)
    S3L_array_t        A
    S3L_array_t        B
    int                axis1
    int                axis1

F77/F90 Syntax


Example 8-78

include `s3l/s3l-f.h'
include `s3l/s3l_errno-f.h'
subroutine
S3L_gen_lsq(A, B, axis1, axis2, ier)
    integer*8          A
    integer*8          B
    integer*4          axis1
    integer*4          axis2
    integer*4          ier

Input

Output

This function uses the following argument for output:

Error Handling

On success, S3L_gen_lsq returns S3L_SUCCESS.

S3L_gen_lsq checks the validity of the array arguments. If an array argument is found to be corrupted or invalid, an error code is returned. See Appendix A of this manual for a detailed list of these error codes.

In addition, the following conditions will cause the function to terminate and return the associated error code.

Examples

../examples/s3l/lsq/ex_lsq.c
../examples/s3l/lsq-f/ex_lsq.f