Skip to content
Snippets Groups Projects
Commit 1385a8c5 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

corr concatenation of coord names

parent a6e12679
No related branches found
No related tags found
No related merge requests found
......@@ -322,7 +322,7 @@ CFunc* NFunctions::find(string s)
//* Coordinate concatenation *//
//**************************************************************************//
CCoord CFunc::coord(CCoord *co1) const
CCoord CFunc::coord( CCoord *co1 ) const
{
CCoord co = *co1;
if (s=="1/") {
......@@ -347,25 +347,34 @@ CCoord CFunc::coord(CCoord *co1) const
} else if (s=="abs") {
co.name = "abs (" + co1->name + ")";
} else if (s=="") {
} else {
co.name = s + "(" + co1->name + ")";
}
return co;
}
CCoord CFunc::coord(class CCoord *co1, class CCoord *co2) const
CCoord CFunc::coord( class CCoord *co1, class CCoord *co2 ) const
{
CCoord co = *co1;
if (s=="+" || s=="-") {
co.name = co1->name + s + co2->name;
if ( co1->unit=="" )
co.unit = "";
else if ( co2->unit!="" && co2->unit != co1->unit) {
cout << "? different units " << co1->unit << " and " <<
co2->unit << " in additive operation\n";
co.unit = "";
} else
co.unit = co1->unit;
} else if (s=="*" || s=="/") {
if ( s=="+" || s=="-" ) {
if( co1->name!=co2->name ){
if( co1->unit!=co2->unit )
throw string( "same coordinate name and different units"
" in additive operation" );
co = *co1;
} else {
co.name = co1->name + s + co2->name;
if ( co1->unit=="" )
co.unit = "";
else if ( co2->unit!="" && co2->unit!=co1->unit) {
cout << "? different units " << co1->unit << " and " <<
co2->unit << " in additive operation\n";
co.unit = "";
} else
co.unit = co1->unit;
}
} else if ( s=="*" || s=="/" ) {
co.name = co1->name + s + co2->name;
if ( co1->unit!="" && co2->unit!="" )
co.unit = co1->unit + s + co2->unit;
......@@ -375,7 +384,7 @@ CCoord CFunc::coord(class CCoord *co1, class CCoord *co2) const
co.unit = s=="*" ? co2->unit : "1/(" + co2->unit + ")";
else
co.unit = "";
} else if (s=="^") {
} else if ( s=="^" ) {
if (co2->unit != "") {
cout << "? exponent is not dimensionless\n";
}
......@@ -385,8 +394,8 @@ CCoord CFunc::coord(class CCoord *co1, class CCoord *co2) const
return co;
}
CCoord CFunc::coord(class CCoord *co1, class CCoord *co2,
class CCoord *co3) const
CCoord CFunc::coord( class CCoord *co1, class CCoord *co2, class CCoord *co3 )
const
{
CCoord co = *co2;
return co;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment