[SciPy-user] howto dot(a, b.T), some a or b coords are zeros

dmitrey dmitrey.kroshko@scipy....
Thu Jan 3 03:30:06 CST 2008


Alan G Isaac wrote:
> On Wed, 02 Jan 2008, dmitrey apparently wrote:
>   
>> I have 2 vectors a and b of shape (n, 1) (n can be 
>> 1...10^3, 10^4, may be more); some coords of a or 
>> b usually are zeros (or both a and b, but b is more 
>> often); getting matrix c = dot(a, b.T) is required 
>> (c.shape = (n,n))
>>     
>
> Are you sure you need c explicitly?
>   
Yes
> How exactly is it used?
> (I.e., what is the algebraic expression
> in which c is used?)
>   
here's a part of ralg code:
B is n x n matrix, g, g1, g2 are n x 1 vectors, w is real number
###################
for i in xrange(p.maxIter):
    ...
    g2 = dot(B, g)
    g1 = dot(B, g2)
    ...
    g2 = <getting vector with possible lots of zeros>
    g1 = <some func from g2, with possible lots of zeros>
    g = dot(B, g1)
    B += dot(dot(B,g), g*w) <- here I intend to get some economy
    g = g2.copy()
###################

For some initial iterations, when initial point is infeasible and max 
constraint derivative depends on some coords only (or feasible + objfun 
depends on some coords only), dot(B, g1) has lots of zeros (for example, 
n-1 zeros for box-bound constraints), as well as dot(B, g) or g*w.
This cases are especially important to ralg-based solver nssolve.

Regards, D.



More information about the SciPy-user mailing list