close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 15 years ago

Closed 15 years ago

#868 closed defect (fixed)

fallo en triplet

Reported by: Jorge Owned by: Víctor de Buen Remiro
Priority: highest Milestone: Mantainance
Component: Math Version: 2.0.1
Severity: critical Keywords: Triplet
Cc: lcereceda@…

Description

Parece que hay un fallo en triplet.

Hay una celda que en el Set triplet es > 0 y en la vmatriz es 0. El conjunto triplet no tiene repeticiones.

Se adjunta un codigo test y datos.

Attachments (2)

test.tol (1.1 KB) - added by Jorge 15 years ago.
triplet.oza (27.7 KB) - added by Jorge 15 years ago.

Download all attachments as: .zip

Change History (5)

Changed 15 years ago by Jorge

Attachment: test.tol added

Changed 15 years ago by Jorge

Attachment: triplet.oza added

comment:1 Changed 15 years ago by Víctor de Buen Remiro

Component: KernelMath
Milestone: Manteinance
Status: newaccepted

El error aparece sólo cuando se le pasa un Set en lugar de una matriz a Triplet. Esto es facil de ver con el siguiente test simplificado

Set triplet = {Set Include( "triplet.oza" )[1]};
Set uniqueTriple = Classify( triplet, Real( Set a, Set b ) {
    Real cmp1 = Compare(a[1],b[1]);
    If( cmp1, cmp1, Compare( a[2],b[2] ) )
 } );
Real ok.1 = Eq( Card( uniqueTriple ), Card( triplet ) );
WriteLn( "ok.1 = Eq( Card( uniqueTriple ), Card( triplet ) ) = " << ok.1 );
Real check_idx = 637;
Real check_r = triplet[check_idx][1]; //284;
Real check_c = triplet[check_idx][2]; //137;
Real check_x = triplet[check_idx][3]; //0.16148984275;
Matrix T = SetMat(triplet);
Real M = MatMax(SubCol(T,[[1]]));
Real N = MatMax(SubCol(T,[[2]]));
VMatrix A1 = Convert( Triplet      ( T, M, N ), "Cholmod.R.Sparse" );
VMatrix A2 = Convert( TripletUnique( T, M, N ), "Cholmod.R.Sparse" );
VMatrix diff = A2 - A1;
Real ok.2 = 1 - VMatMax( Abs( diff ) );
WriteLn( "ok.2 = 1-Max(Abs(diff)) = " << ok.2 );
Real cell1 = VMatDat( A1, check_r, check_c );
Real ok.3.1 = 1 - (cell1 - check_x);
Real cell2 = VMatDat( A2, check_r, check_c );
Real ok.3.2 = 1- (cell2 - check_x);
WriteLn( "T["<<check_r+","<<check_c+"]="<<check_x);
WriteLn( "A1["<<check_r+","<<check_c+"]="<<cell1);
WriteLn( "A2["<<check_r+","<<check_c+"]="<<cell2);}}}

Esto devuelve el resultado esperado

{{{
ok.1 = Eq( Card( uniqueTriple ), Card( triplet ) ) = 1
ok.2 = 1-Max(Abs(diff)) = 1
T[284,137]=0.1614898427500973
A1[284,137]=0.1614898427500973
A2[284,137]=0.1614898427500973
}}}

Creo que lo más sencillo será eliminar la función de BVMat que usa el Set y que sea la función built-in la que internamente llame a SetMat y así se simplifica todo.

comment:2 Changed 15 years ago by Jorge

Cc: lcereceda@… added; lcereceda@… removed

comment:3 Changed 15 years ago by Víctor de Buen Remiro

Resolution: fixed
Status: acceptedclosed

Sorry, the commit of changes to solve this bug was assigned to ticket #864 by a mistake. It should be

(In [2020]) Fixed #868
BVMat::Set2triplet methods are removed
Built-in function Matrix SetMat? has been generalized as internal_builtin_SetMat to be called by built-in function VMatrix Triplet

Note: See TracTickets for help on using tickets.