[ 1 = 1+0i ] <=> [ 1 = 1 ]

66 views
Skip to first unread message

ph h

unread,
May 24, 2022, 10:14:30 PM5/24/22
to sage-devel
Dear All,

Is this feasible [ 1 = 1+0i  ] <=> [ 1 = 1 ] ?

Regards,

phiho

<src.bin.sage-env>
if [ 1 = 1+0i ]; then      
# Make sure that SAGE_ROOT is either an absolute physical directory name
# or empty.
# An absolute physical directory name has already been embedded and exported
# at configuration time.
#if [ -n "$SAGE_ROOT" ]; then
#    export SAGE_ROOT=$(cd "$SAGE_ROOT" 2>/dev/null && pwd -P)
#fi

#if [ -d "$SAGE_ROOT" ]; then

    export SAGE_LOGS="$SAGE_ROOT/logs/pkgs"
    export SAGE_SRC="$SAGE_ROOT/src"
    export SAGE_DOC_SRC="$SAGE_SRC/doc"
    export PATH="$SAGE_ROOT/build/bin:$PATH"
    if [ -z "$SAGE_DISTFILES" ]; then
        SAGE_DISTFILES="$SAGE_ROOT/upstream"
        export SAGE_DISTFILES
    fi
    if [ -z "$CCACHE_BASEDIR" ]; then
        export CCACHE_BASEDIR="$SAGE_ROOT"
    fi
#fi
fi    # [ 1 = 1+0i ]
</src.bin.sage-env>

<sage-env>
if [ 1 = 1 ]; then
# Make sure that SAGE_ROOT is either an absolute physical directory name
# or empty.
if [ -n "$SAGE_ROOT" ]; then
    export SAGE_ROOT=$(cd "$SAGE_ROOT" 2>/dev/null && pwd -P)
fi
[...]
if [ -d "$SAGE_ROOT" ]; then
    export SAGE_LOGS="$SAGE_ROOT/logs/pkgs"
    export SAGE_SRC="$SAGE_ROOT/src"
fi
[...]
if [ -n "$SAGE_SRC" ]; then
    export SAGE_DOC_SRC="$SAGE_SRC/doc"
fi
[...]
if [ -d "$SAGE_ROOT" ]; then
    export PATH="$SAGE_ROOT/build/bin:$PATH"
fi
[...]
if [ -d "$SAGE_ROOT" ]; then
    if [ -z "$SAGE_DISTFILES" ]; then
        SAGE_DISTFILES="$SAGE_ROOT/upstream"
        export SAGE_DISTFILES
    fi
fi
[...]
if [ -d "$SAGE_ROOT" -a -z "$CCACHE_BASEDIR" ]; then
    export CCACHE_BASEDIR="$SAGE_ROOT"
fi
fi      # [ 1 = 1 ]

if [ 1 = 2 ]; then
    echo "The following enviroment variables can be set by the user"
    echo "AR          The archiver (e.g. ar, /usr/ccs/bin/ar or /usr/bin/ar)"
    echo "AS          The assembler (e.g. as, /usr/ccs/bin/as or /usr/bin/as)"
    echo "CC          The C compiler (e.g cc, /opt/SUNWspro/bin/cc or /usr/bin/gcc)"
    echo "CFLAGS      Flag(s) for the C compiler (e.g.  -g -Wall -O2)"
    echo "            (You are advised to a some optimisation flag(s), such as -O2 or -xO2 to CFLAGS)"
    echo "CXX         The C++ compiler (e.g g++, /opt/SUNWspro/bin/CC or /usr/local/bin/g++)"
    echo "CXXFLAGS    Flag(s) for the C++ compiler (e.g. -fast -fsimple=1 -x04)"
    echo "LD          The linker (e.g. ld, /usr/ccs/bin/ld or /usr/bin/ld)"
    echo "LDFLAGS     Linker flag(s) (e.g. -D token)"
    echo "LN          Used to make links (e.g. ln, /usr/xpg4/bin/ln or /usr/bin/ln)"
    echo "MAKE        The make program (e.g. make, /usr/bin/make or /usr/local/bin/gmake)"
    echo "MAKEFLAGS   Flag(s) to make (e.g. -j4)."
    echo "RANLIB      Archiver ranlib (e.g. ranlib, /usr/ccs/bin/ranlib etc)"
    echo "SHAREDFLAGS Flag(s) necessary for building a shared library (e.g. -fPIC or -xcode=pic32)"
    echo "We attempt to set this to sensible values, but check below to"
    echo "ensure they are OK. If you wish to override any then please use:"
    echo "setenv NAME_OF_ENVIROMENT_VARIABLE value_of_enviroment_variable"
    echo "(if you use tcsh, csh or a similar shell) or"
    echo "NAME_OF_ENVIROMENT_VARIABLE value_of_enviroment_variable"
    echo "export NAME_OF_ENVIROMENT_VARIABLE"
    echo "if you use sh, bash or a similar shell"
fi
</sage-env>

ph h

unread,
May 25, 2022, 8:38:43 AM5/25/22
to sage-...@googlegroups.com
P.S: Sorry, there was a typo here:
# at configuration time.

should read

# at validating time.


--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/0e5b5d21-9dda-492a-b427-ea0d7104505an%40googlegroups.com.

John H Palmieri

unread,
May 26, 2022, 12:46:28 AM5/26/22
to sage-devel
Are you asking whether a shell script can handle complex arithmetic? What does that have to do with Sage?

If that's not what you're asking, please clarify.

ph h

unread,
May 26, 2022, 7:26:55 PM5/26/22
to sage-...@googlegroups.com
Hi there,

> Are you asking whether a shell script can handle complex arithmetic? What does that have to do with Sage?
Maybe it's just wishful thinking. One day, SageMath may have it's own shell (smiley)

> If that's not what you're asking, please clarify.

Maybe just another wishful thinking, how to make [ 1 = 1+0i ] evaluate to 'true' with a tiny bit (0) of imaginary part (smiley)
Thank you for your help, it is much appreciated.

All the best,

phiho



Nils Bruin

unread,
May 27, 2022, 5:36:59 AM5/27/22
to sage-devel
On Friday, 27 May 2022 at 01:26:55 UTC+2 hohoa...@gmail.com wrote:
Hi there,

> Are you asking whether a shell script can handle complex arithmetic? What does that have to do with Sage?
Maybe it's just wishful thinking. One day, SageMath may have it's own shell (smiley)

A shell is a programming language, and sage has one: python. In fact, ipython (the interface used by sage) has some features to make it slightly more palatable as a CLI for operating system use:


However, on the side of "bash": semantically, commands like [...] are just process invocations. It's only for efficiency that they're implemented within the bash process itself.

You can already do:

$ sage -c "sys.exit( not(1==0))" || echo "false"
false
$ sage -c "sys.exit( not(1==1))" && echo "true"
true

so you can get sage results for logical flow control in bash already (note that in bash 0 means "true" and 1 means "false"; hence the confusing "not".

You can use this in bash "if" statements as well; look up the "test" spelling of "[ .. ]" (and there actually is a /usr/bin/test executable)
Reply all
Reply to author
Forward
0 new messages