import sys
import ctypes
import numpy as np

x0 = float(sys.argv[1])

print (" FIRST: x, in place")
x = x0
x = np.array(x)
import modSquare
modSquare.my_square(x)
print (" x square F,", x)

x = x0
my_code = ctypes.CDLL("./my_square.so")
my_code.my_square.argtypes = \
  [ctypes.POINTER(ctypes.c_double)]
x = ctypes.c_double(x)
my_code.my_square(ctypes.byref(x))
x = x.value
print (" x square C,", x)

print ("\n SECOND: x2 = x * x")
x = x0
x = np.array(x)
import mod2Square
x2 = mod2Square.my_2square(x)
print (" x square F,", x2)

x = x0; x2 = 0
my_code = ctypes.CDLL("./my_2square.so")
my_code.my_2square.argtypes = \
  [ctypes.c_double, ctypes.POINTER(ctypes.c_double)]
x = ctypes.c_double(x)
x2 = ctypes.c_double(x2)
my_code.my_2square(x, ctypes.byref(x2))
x2 = x2.value
print (" x square C,", x2)
print ("\n End of program")
