@@ -595,6 +595,17 @@ class opTrans : public OneOperator{
595595 E_F0 * code (const basicAC_F0 & args) const {
596596 return new TransE_Array (dynamic_cast <const E_Array*>((Expression) args[0 ])); }
597597};
598+ class opUnary : public OneOperator {
599+ public:
600+ const char * op;
601+ AnyType operator ()(Stack s) const {ffassert (0 );return 0L ;}
602+ bool MeshIndependent () const { return false ;}
603+
604+ opUnary (const char * oop,aType A): OneOperator(atype<C_F0>(),A), op(oop) {}
605+
606+ E_F0 * code (const basicAC_F0 & ) const {ffassert (0 );}
607+ C_F0 code2 (const basicAC_F0 &args) const ;
608+ };
598609
599610class opDot : public OneOperator {
600611public:
@@ -1422,6 +1433,11 @@ void Init_map_type()
14221433 TheOperators->Add (" ./" ,new opSum (" /" ,atype<E_Array >(),atype<TransE_Array>() ) ); // a faire mais dur
14231434 // correct in sept. 2009
14241435 TheOperators->Add (" ./" ,new opSum (" /" ,atype<TransE_Array >(),atype<TransE_Array>() ) ); // a faire mais dur
1436+ // Add sep 2025
1437+ TheOperators->Add (" -" ,new opUnary (" -" ,atype<E_Array >()) );
1438+ TheOperators->Add (" -" ,new opUnary (" -" ,atype<TransE_Array >()) );
1439+ TheOperators->Add (" +" ,new opUnary (" +" ,atype<E_Array >()) ); //
1440+ TheOperators->Add (" +" ,new opUnary (" +" ,atype<TransE_Array >()) );
14251441
14261442
14271443 // il faut refechir ..... FH
@@ -1926,6 +1942,7 @@ C_F0 opDot::code2(const basicAC_F0 &args) const
19261942 return C_F0 ();
19271943
19281944}
1945+
19291946C_F0 opColumn::code2 (const basicAC_F0 &args) const
19301947{
19311948 bool ta =args[0 ].left ()==atype<TransE_Array>();
@@ -2045,11 +2062,72 @@ C_F0 opColumn::code2(const basicAC_F0 &args) const
20452062 else ffassert (0 );
20462063 return C_F0 ();
20472064}
2065+ C_F0 opUnary::code2 (const basicAC_F0 &args) const
2066+ {
2067+ bool ta =args[0 ].left ()==atype<TransE_Array>();
2068+ const TransE_Array * tea=0 ;
2069+ const E_Array * ea=0 ;
2070+ if ( ta) tea = dynamic_cast <const TransE_Array*>((Expression) args[0 ]);
2071+ else ea = dynamic_cast <const E_Array*>((Expression) args[0 ]);
2072+ assert ( ea || tea );
2073+ const E_Array & a= ta ? *tea->v : *ea;
2074+ int na=a.size ();
2075+ if (na <1 && nb < 1 ) CompileError (" empty array - [ ...] " );
2076+ bool maa= a[0 ].left ()==atype<E_Array>();
2077+ int ma =1 ;
2078+
2079+ if (maa) {
2080+ ma= a[0 ].LeftValue ()->nbitem ();
2081+ for (int i=1 ;i<na;i++)
2082+ if ( ma != (int ) a[i].LeftValue ()->nbitem ())
2083+ CompileError (" first matrix with variable number of columm" );
2084+
2085+ }
2086+ int na1=na,ma1=ma;
2087+ if (ta) RNM::Exchange (na1,ma1);
2088+
2089+ KNM<CC_F0> A (na1,ma1) ;
2090+ if (maa)
2091+ for (int i=0 ;i<na;++i)
2092+ {
2093+ const E_Array * li= dynamic_cast <const E_Array *>(a[i].LeftValue ());
2094+ ffassert (li);
2095+ for (int j=0 ; j<ma;++j)
2096+ if (!ta) A (i,j) = (*li)[j];
2097+ else A (j,i) = TryConj ((*li)[j]);
2098+ }
2099+ else
2100+ for (int i=0 ;i<na;++i)
2101+ if (!ta) A (i,0 ) = a[i];
2102+ else A (0 ,i) = TryConj (a[i]);
20482103
2104+
2105+ AC_F0 v;
2106+ v = 0 ; // empty
2107+ if ( ma1 == 1 ) // 1 vecteur
2108+ {
2109+ for (int i=0 ;i<na;++i)
2110+ v += C_F0 (TheOperators,op,ta ? TryConj (a[i]) : a[i]) ;
2111+ return C_F0 (TheOperators," []" ,v);
2112+ }
2113+ else {
2114+ // return formal matrix
2115+ AC_F0 w,v;
2116+ w=0 ;
2117+ for (int i=0 ;i<na1;++i)
2118+ {
2119+ v=0 ;
2120+ for (int j=0 ;j<ma1;++j)
2121+ v+= C_F0 (TheOperators,op,A (i,j));
2122+ w+=C_F0 (TheOperators," []" ,v);
2123+ }
2124+ return C_F0 (TheOperators," []" ,w);
2125+ }
2126+ }
20492127
20502128C_F0 opSum::code2 (const basicAC_F0 &args) const
20512129{
2052-
2130+
20532131 bool ta =args[0 ].left ()==atype<TransE_Array>();
20542132 bool tb = args[1 ].left ()==atype<TransE_Array>();
20552133 const TransE_Array * tea=0 ;
@@ -2137,7 +2215,7 @@ C_F0 opSum::code2(const basicAC_F0 &args) const
21372215 {
21382216 v=0 ;
21392217 for (int j=0 ;j<ma1;++j)
2140- v+= C_F0 (TheOperators," + " ,A (i,j),B (i,j));
2218+ v+= C_F0 (TheOperators,op ,A (i,j),B (i,j));// correction 3/9/25 FH thanks to O. Pantz
21412219 w+=C_F0 (TheOperators," []" ,v);
21422220 }
21432221 return C_F0 (TheOperators," []" ,w);
0 commit comments