This is Matlab's code:

[Q,S] = svd(A,'econ'); %S is always square.

if ~isempty(S)

    S = diag(S);

    tol = max(size(A)) * S(1) * eps(class(A));

    r = sum(S > tol);

    Q = Q(:,1:r);

end




Op maandag 30 juni 2014 07:53:19 UTC+2 schreef Andre P.:
>
> I have some Matlab code I'm porting to Julia
>
> BiasHN = rand(HN(i+1),1)*2 -1;
> BiasHN = orth(BiasHN);
>
> Was the equivalent of the orth() from Matlab added to Julia? Can't seem to 
> find it.
>
> Andre
>
> On Thursday, April 3, 2014 10:32:31 PM UTC+9, Alan Edelman wrote:
>>
>> Maybe something like this
>>
>> function orth(A,thresh=eps(A[1]))   
>>  (U,S)=svd(A)
>>  U[:, S.>S[1]*thresh]
>> end
>>
>> orth(float(A))
>>
>> 20x4 Array{Float64,2}:
>>
>>  -0.223607  -0.213651    0.183753    0.265684 
>>
>>  -0.223607  -0.213651    0.183753    0.265684 
>>
>>  -0.223607  -0.213651    0.183753    0.265684 
>>
>>  -0.223607  -0.213651    0.183753    0.265684 
>>
>>  -0.223607  -0.213651    0.183753    0.265684 
>>
>>  -0.223607   0.0371419  -0.372503    0.0993058
>>
>>  -0.223607   0.0371419  -0.372503    0.0993058
>>
>>  -0.223607   0.0371419  -0.372503    0.0993058
>>
>>  -0.223607   0.0371419  -0.372503    0.0993058
>>
>>  -0.223607   0.0371419  -0.372503    0.0993058
>>
>>  -0.223607   0.350358    0.163883   -0.0197973
>>
>>  -0.223607   0.350358    0.163883   -0.0197973
>>
>>  -0.223607   0.350358    0.163883   -0.0197973
>>
>>  -0.223607   0.350358    0.163883   -0.0197973
>>
>>  -0.223607   0.350358    0.163883   -0.0197973
>>
>>  -0.223607  -0.173849    0.0248676  -0.345193 
>>
>>  -0.223607  -0.173849    0.0248676  -0.345193 
>>
>>  -0.223607  -0.173849    0.0248676  -0.345193 
>>
>>  -0.223607  -0.173849    0.0248676  -0.345193 
>>
>>  -0.223607  -0.173849    0.0248676  -0.345193
>>
>>
>>
>>
>> On Thursday, April 3, 2014 9:23:14 AM UTC-4, Alan Edelman wrote:
>>>
>>> I would use the svd with a threshold based on the norm
>>> and optionally adjustable
>>>
>>>

Reply via email to