﻿ g02bw Method
g02bw calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products of deviations about the mean.

# Syntax

C#
```public static void g02bw(
int m,
double[] r,
out int ifail
)```
Visual Basic
```Public Shared Sub g02bw ( _
m As Integer, _
r As Double(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g02bw(
int m,
array<double>^ r,
[OutAttribute] int% ifail
)```
F#
```static member g02bw :
m : int *
r : float[] *
ifail : int byref -> unit
```

#### Parameters

m
Type: System..::..Int32
On entry: $m$, the number of variables.
Constraint: ${\mathbf{m}}\ge 1$.
r
Type: array<System..::..Double>[]()[][]
An array of size [$\left({\mathbf{m}}×{\mathbf{m}}+{\mathbf{m}}\right)/2$]
On entry: contains the upper triangular part of the sums of squares and cross-products matrix of deviations from the mean. These are stored packed by column, i.e., the cross-product between variable $j$ and $k$, $k\ge j$, is stored in ${\mathbf{r}}\left[\left(k×\left(k-1\right)/2+j\right)-1\right]$.
On exit: Pearson product-moment correlation coefficients.
These are stored packed by column corresponding to the input cross-products.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

g02bw calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products about the mean for observations on $m$ variables which can be computed by a single call to g02bu or a series of calls to g02bt. The sums of squares and cross-products are stored in an array packed by column and are overwritten by the correlation coefficients.
Let ${c}_{jk}$ be the cross-product of deviations from the mean, for $\mathit{j}=1,2,\dots ,m$ and $\mathit{k}=j,\dots ,m$, then the product-moment correlation coefficient, ${r}_{jk}$ is given by
 $rjk=cjkcjjckk.$

None.

# Error Indicators and Warnings

Note: g02bw may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{m}}<1$.
${\mathbf{ifail}}=2$
A variable has a zero variance. All correlations involving the variable with zero variance will be returned as zero.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

The accuracy of g02bw is entirely dependent upon the accuracy of the elements of array r.

None.