## ZGESDD return value for VT when JOBZ is 'A' and M<N

Open discussion regarding features, bugs, issues, vendors, etc.

### ZGESDD return value for VT when JOBZ is 'A' and M<N

In the docs for the VT parameter for ZGESDD, we find the statement:

"If JOBZ = 'A' or JOBZ = 'O' and M >= N, VT contains the N-by-N unitary matrix V**H;"

We aren't sure whether to parse this as:

"If (JOBZ = 'A') or (JOBZ = 'O' and M >= N), VT contains the N-by-N unitary matrix V**H;"

or as

"If (JOBZ = 'A' or JOBZ = 'O') and M >= N, VT contains the N-by-N unitary matrix V**H;"

The former seems likely since the docs for JOBZ say that if JOBZ is 'A', then "all M columns of U and all N rows of V**H are returned in the arrays U and VT;". However, just in case, can someone clarify how we should parse the above statement for the return value VT?

We (members of the Sage [1] and numpy development communities) are finding that on certain Mac OSX 10.5 machines using the Accelerate framework (IIRC), for 3x4 and other matrices where M<N, the last row of the returned VT appears to be all zeroes when JOBZ is 'A'. We can post more detailed example programs and output if needed.

Thanks,

Jason Grout

[1] http://www.sagemath.org
jasongrout

Posts: 2
Joined: Tue Apr 26, 2011 3:48 pm

### Re: ZGESDD return value for VT when JOBZ is 'A' and M<N

This should be parsed as:
jasongrout wrote:"If (JOBZ = 'A') or (JOBZ = 'O' and M >= N), VT contains the N-by-N unitary matrix V**H;"

jasongrout wrote:We (members of the Sage [1] and numpy development communities) are finding that on certain Mac OSX 10.5 machines using the Accelerate framework (IIRC), for 3x4 and other matrices where M<N, the last row of the returned VT appears to be all zeroes when JOBZ is 'A'. We can post more detailed example programs and output if needed.

This is not an expected behavior. Happy to get an example code.

Cheers,
Julien.
Julien Langou

Posts: 824
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

### Re: ZGESDD return value for VT when JOBZ is 'A' and M<N

The example program is based on an example by Intel, so I don't know if it's okay to post the full text. Instead, I posted this patch to this example program.

Here is an example of the issue, posted here. First, the system information:
Code: Select all
`\$ sw_versProductName:   Mac OS XProductVersion:   10.5.8BuildVersion:   9L31a\$ xcodebuild -versionXcode 3.1.4Component versions: DevToolsCore-1204.0; DevToolsSupport-1186.0BuildVersion: 9M2809\$ gcc --versioni686-apple-darwin9-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5577)Copyright (C) 2007 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\$ uname -aDarwin U 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386`

and here is the output of the sample program:
Code: Select all
`\$ gcc test_zgesdd.c -o test_zgesdd -framework Accelerate\$ ./test_zgesdd ZGESDD Example Program Results Original Matrix ( -5.400000000,  7.400000000) (  6.000000000,  6.380000000) (  9.910000000,  0.160000000) ( -5.280000000, -4.160000000) (  1.090000000,  1.550000000) (  2.600000000,  0.070000000) (  3.980000000, -5.260000000) (  2.030000000,  1.110000000) (  9.880000000,  1.910000000) (  4.920000000,  6.310000000) ( -2.110000000,  7.390000000) ( -9.810000000, -8.980000000) Singular values  21.755192792  16.595450169   3.973275762 Left singular vectors (stored columnwise) (  0.547427636,  0.000000000) (  0.763021682,  0.000000000) ( -0.343687207,  0.000000000) ( -0.035076841, -0.151484384) (  0.270976798, -0.226375144) (  0.545726276, -0.743862082) (  0.812990162,  0.123256143) ( -0.523110953, -0.139566162) (  0.133575771, -0.113528196) Right singular vectors (stored rowwise) (  0.231605313,  0.206697957) (  0.365908960,  0.386461298) (  0.242593279,  0.328338539) ( -0.561339324, -0.372335466) ( -0.579119055,  0.403296993) (  0.109213979,  0.172424216) (  0.596738013, -0.274928122) (  0.159988103,  0.055108351) (  0.604200724,  0.123371344) ( -0.189887497,  0.297220678) (  0.392106353,  0.196976354) (  0.454514329,  0.310150370) (  0.000000000,  0.000000000) (  0.000000000,  0.000000000) (  0.000000000,  0.000000000) (  0.000000000,  0.000000000) Last row entries of Right singular vectors (stored rowwise) are zero? True   True   True   True  `
jasongrout

Posts: 2
Joined: Tue Apr 26, 2011 3:48 pm

### Re: ZGESDD return value for VT when JOBZ is 'A' and M<N

Jason,

Julien is correct, the VT parameter documentation should be interpreted as: "If (JOBZ = 'A') or (JOBZ = 'O' and M >= N), VT contains the N-by-N unitary matrix V**H;"

With JOBZ="A", the expected behavior is for VT to be N x N; the last row should not be zero. However, with JOBZ="S", as in the original test code, only the first M rows of VT are computed, so seeing zeros (or sometimes other values) in the last (4th) row of VT for the test problem with M<N is normal.

I tried the test code with JOBZ="A" on MacOS 10.6.7 (with Xcode 4.0) and got the following:

Code: Select all
` ZGESDD Example Program Results Singular values  21.76  16.60   3.97 Left singular vectors (stored columnwise) (  0.55,  0.00) (  0.76,  0.00) ( -0.34,  0.00) ( -0.04, -0.15) (  0.27, -0.23) (  0.55, -0.74) (  0.81,  0.12) ( -0.52, -0.14) (  0.13, -0.11) Right singular vectors (stored rowwise) (  0.23,  0.21) (  0.37,  0.39) (  0.24,  0.33) ( -0.56, -0.37) ( -0.58,  0.40) (  0.11,  0.17) (  0.60, -0.27) (  0.16,  0.06) (  0.60,  0.12) ( -0.19,  0.30) (  0.39,  0.20) (  0.45,  0.31) ( -0.08,  0.14) (  0.70, -0.26) ( -0.15,  0.43) (  0.46,  0.02)`

Also, I tried the same input matrix with LAPACK 3.3.1 and my own test code and got the same result.

So...I'm not sure what is going on with MacOS 10.5.8, maybe there is a bug in the older version of the Accelerate framework that is causing the problem.

--Rodney
rodney

Posts: 49
Joined: Thu Feb 10, 2011 8:20 pm