Calculations by SmartCnsl and Python Sf:1/??


We need to make expressions more similar to usual mathematical ones. Python numpy/scipy, etc packages/modules are very useful for mathematical calculations. But they are limited by Python syntax. You must write multiply operator all the time. Although mathematical expressions omit multiply operator almost every time. You can’t write Greek characters until python 3000. Although mathematical expressions include Greek characters many times. There is no symbolic representation that notate a matrix/vector in Python. You must call a function as numpy.array([…])


So we introduced a preprocessor and extend Python syntax upper compatibly and extend name space to avoid conflicts between Python and mathematics



Optimally customizing Python sf for each application field, it become possible to calculate by a one-liner for more than 90 percent. In mathematics one-liners are adequate for a units of consideration.


You can download free portable Python sf from hear

-------------------------------------------------------
----------- Python sf Preprocessor -------------------
-------------------------------------------------------


We have extended Python syntax upper compatibly and make enable to calculate expressions similar to usual mathematical ones as below.


Multiply operator should be omissible.


a,b = 2,3; 4 a b    # 4 * a * b == 24
===============================
24


"a,b = 2,3; 4 a b # 4 * a * b == 24" string is pass to a pre-processor module sfPP.py. For this string, Actually python -u -m sfPP.py "a,b = 2,3; 4 a b # 4 * a * b == 24" command must be executed.



Probably you want to now the value of the last expression in a series of Python sf expressions. So, Python sf preprocessor automatically print out the last value to a console. You can omit the print instruction.


If you use SmartCnsl plugin menu:pysf -->C then the plugin add python -u -m sfPP.py with double quotations and execute the python command. It is very convenient for calculations.


Hereafter we write only Python sf expressions and omit python -u -m sfPP.py.


Because Python sf is upper compatible for Python, you can write a multply operator and other Python expressions if you want them.


a,b = 2,3; 4 a b == 4*a*b == 24
===============================
True


Basic numeric functions should be in a global name space.


Basic numeric functions: exp, sin, cos, tan, sinh, cosh, tanh, arcsin, arccos, arctan, log, log10, sqrt are in global name space in Python sf. They could be used without import.


a,b = pi/6, pi/3; sin(a+b)
===============================
1.0

sin(3+4j)
===============================
(3.85373803792-27.016813258j)


a,b = pi/6, pi/3; sin([a,b])
===============================
[ 0.5        0.8660254]
---- ClTensor ----

a,b = pi/6, pi/3; sin([[a,b, a+b],[4,5,6]])
===============================
[[ 0.5         0.8660254   1.        ]
 [-0.7568025  -0.95892427 -0.2794155 ]]
---- ClTensor ----


These basic numeric functions can calculate for complex numbers. They can calculate a sequence of numbers. The result is a vector or matrix.


^ operator should be usable for power operations
At Python syntax, ^ operator is bit exclusive or. But it is quietly confined to use bit exclusive or. On the other side, ^ is used commonly as a power operator in mathematics. So in Python sf, ^ operator is a power operator. If you want to use bit exclusive or in Python sf, you must use \^. Of course, you can use ** operator as another power operator.


2^4
===============================
16

2**4
===============================
16

2\^4
===============================
6


Matrix/vector should be describes easily as far as possible and be operated similarly as usual four operations


So we introduce ~[...] representation for matrix/vector and extended numpy.ndarray to ClTensor class.


~[1,2,3]                # a vector representation in Python sf
===============================
[ 1.  2.  3.]
---- ClTensor ----

vct=~[1,2,3]; 2 vct     # scalar * default float vector 
===============================
[ 2.  4.  6.]
---- ClTensor ----

v1,v2=~[1,2,3],~[4,5,6]; v1+v2     # add vectors
===============================
[ 5.  7.  9.]
---- ClTensor ----

v1,v2=~[1,2,3],~[4,5,6]; v1 v2     # inner product
===============================
32.0

v1,v2=~[1,2,3],~[4,5,6]; v1^v2     # diadic: outer product
===============================
[[  4.   5.   6.]
 [  8.  10.  12.]
 [ 12.  15.  18.]]
---- ClTensor ----

vct=~[1,2,3,int]; 2 vct     # scalar * vector designeted as integer type
===============================
[2 4 6]
---- ClTensor ----


Usually numerical calculation is performed as float/complex numbers. If integer type vectors or matrices are used, there might be many error calculations eliminating numbers after the decimal point.


~[[1,2,3],[4,5,6]]  # a matrix representation in Python sf
===============================
[[ 1.  2.  3.]
 [ 4.  5.  6.]]
---- ClTensor ----

mt=~[[1,2,3],[4,5,6]]; 2 mt  # scalr * matrix
===============================
[[  2.   4.   6.]
 [  8.  10.  12.]]
---- ClTensor ----

mt,vct=~[[1,2,3],[4,5,6]], ~[7,8,9]; mt vct  # matrx * vector
===============================
[  50.  122.]
---- ClTensor ----

mt,vct=~[[1,2,3],[4,5,6]], ~[7,8]; vct mt # vector * matrix
===============================
[ 39.  54.  69.]
---- ClTensor ----

mt,lst=~[[1,2,3],[4,5,6]],  [7,8,9]; mt lst  # matrx * list
===============================
[  50.  122.]
---- ClTensor ----

mt,tpl=~[[1,2,3],[4,5,6]],  (7,8,9); mt tpl  # matrx * tuple
===============================
[  50.  122.]
---- ClTensor ----

mt =~[[1,2],[3,4]]; mt^2
===============================
[[  7.  10.]
 [ 15.  22.]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; mt^0
===============================
[[ 1.  0.]
 [ 0.  1.]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; mt^-1   # matrix inverse
===============================
[[-2.   1. ]
 [ 1.5 -0.5]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; 1/mt    # other matrix inverse
===============================
[[-2.   1. ]
 [ 1.5 -0.5]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; mt.inv()# other matrix inverse
===============================
[[-2.   1. ]
 [ 1.5 -0.5]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; mt^2 + 3mt+100mt^0  # a polynomial of a matrix
===============================
[[ 110.   16.]
 [  24.  134.]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; (mt^2+ mt^0)/(mt^2 + 3mt+100mt^0)  # a ratianal expresion of a matrix
===============================
[[ 0.05795486  0.06770688]
 [ 0.10156032  0.15951519]]
---- ClTensor ----

mt=~[[1,2,3],[4,5,6]]; mt.t     # transpose matrx
===============================
[[ 1.  4.]
 [ 2.  5.]
 [ 3.  6.]]
---- ClTensor ----

mt=~[[1,2,3],[4,5,6+7j]]; mt.conj()     # transpose matrx
===============================
[[ 1.-0.j  2.-0.j  3.-0.j]
 [ 4.-0.j  5.-0.j  6.-7.j]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; mt.m_dtrm   # determinant
===============================
-2.0

mt=~[[1,2,3],[4,5,6]]; mt.r     # vector from matrx 
===============================
[ 1.  2.  3.  4.  5.  6.]
---- ClTensor ----



You can use slice operator : for a matrix or vector.


vc=~[1,2,3,4]; vc[:2]
===============================
[ 1.  2.]
---- ClTensor ----

vc=~[1,2,3,4]; vc[2:4]
===============================
[ 3.  4.]
---- ClTensor ----

vc=~[1,2,3,4]; vc[-2:]
===============================
[ 3.  4.]
---- ClTensor ----

vc=~[1,2,3,4]; vc[-2]
===============================
3.0

# assign ment for elements
vc=~[1,2,3,4]; vc[2:4]=[10,11];vc
===============================
[  1.   2.  10.  11.]
---- ClTensor ----

mt=~[[1,2,3],[4,5,6]]; mt[:,0]
===============================
[ 1.  4.]
---- ClTensor ----

mt=~[[1,2,3],[4,5,6]]; mt[1,:]
===============================
[ 4.  5.  6.]
---- ClTensor ----

mt=~[[1,2,3],[4,5,6]]; mt[1,1:]
===============================
[ 5.  6.]
---- ClTensor ----

# assignment for elements
mt=~[[1,2,3],[4,5,6]]; mt[1,1:]=[10,11];mt
===============================
[[  1.   2.   3.]
 [  4.  10.  11.]]
---- ClTensor ----


You can calculate eigen values/vectors, exponential of a matrix, logarithm of a matrix,


mt =~[[1,2],[3,4]]; eig(mt)     # eigen values and eigen vectors
===============================
(ClTensor([-0.37228132,  5.37228132]),
ClTensor([[-0.82456484, -0.41597356],
          [ 0.56576746, -0.90937671]]))
mt =~[[1,2],[3,4]]; expm(mt)    # exponential for a matrix, nor for elements
===============================
[[  51.9689562    74.73656457]
 [ 112.10484685  164.07380305]]
---- ClTensor ----

mt =~[[1,2],[3,4]];  exp(mt)    # exponential for elements
===============================
[[  2.71828183   7.3890561 ]
 [ 20.08553692  54.59815003]]
---- ClTensor ----

mt =~[[1,2],[3,4]]; logm(mt)
===============================
[[-0.35043981+2.39111795j  0.92935121-1.09376217j]
 [ 1.39402681-1.64064326j  1.04358699+0.7504747j ]]
---- ClTensor ----

H =~[[1,2],[3,4]]; [expm(t H) [1,2] for t in (0, 0.1, 0.2, 0.3) ]
===============================
[ClTensor([ 1.,  2.]), ClTensor([ 1.66279504,  3.45576546]), ClTensor([ 2.79877861,  5.94573902]), ClTensor([  4.7444446 ,  10.20555274])]



Calculations by SmartCnsl and Python 2/2


Here I show example codes using numpy/scipy.


I use SmarCnsl to execute Python codes as below.


//@@
import numpy as sc
f=lambda x:sc.sin(10*x+0.1) * sc.cos(x)

print f(sc.pi/6)
print f(sc.pi/6 * 1j)

print sc.fft.fft([1,2,3,4]) # Fast Fourier Transformation
//@@@
-0.703023986477
(10.6958292167+106.595489076j)
[ 10.+0.j  -2.+2.j  -2.+0.j  -2.-2.j]


If you enbale SmartCnsl plugin, you can execute this Python code by

  1. copy all these text to a Editra text
  2. move cursor on a line between //@@ and //@@@
  3. Carrage Return at the menu:pysf –> Y


The executed results will be printed in the Tkinter console window.

---- numpy example 1 ----------------
---- vector/matrix calculations -----


sc.array(..) function makes a vector or matrix. dot(..) function calculates inner product for 2 vector arguments and multiplies for matrix, vector arguments. numpy.linalg sub package has functions to calculate inverse, eigen value/vector, etc.


//@@
import numpy as sc

v1,v2 = sc.array([1,2]), sc.array([4,5])
mt    = sc.array([[1,2],[3,4]])

print "+++++++ vector operation +++++++++++++"
print 7*v1 + 8*v2       # scalar multiply and sum for vectors
print sc.dot(v1,v2)     # inner product
print sc.cross(v1,v2)   # inner product
print sc.sin(v1)        # sin for each element

print "+++++++ matrix operation +++++++++++++"
print sc.dot(mt,v1)     # multipy a vector to amatrix
print sc.dot(v1,mt)     # multipy a vector from left to amatrix

print sc.linalg.inv(mt)  # invers

print "+++++++ eigen values/vectors +++++++++++++"
print sc.linalg.eig(mt)  # eigen value
//@@@
+++++++ vector operation +++++++++++++
[39 54]
14
-3
[ 0.84147098  0.90929743]
+++++++ matrix operation +++++++++++++
[ 5 11]
[ 7 10]
[[-2.   1. ]
 [ 1.5 -0.5]]
+++++++ eigen values/vectors +++++++++++++
(array([-0.37228132,  5.37228132]), 
array([[-0.82456484, -0.41597356],
       [ 0.56576746, -0.90937671]]))

---- numpy example 2 ------------
---- basic functions ------------


Python numpy package includes basic functions exp, sin, cos, tan, sinh, cosh, tanh, arcsin, arccos, arctan, log, log10, sqrt … which can calculate a complex argument, additionally a array argument.


//@@
import numpy as sc

x=sc.pi/6
print sc.exp(x)
print sc.sin(x)
print sc.cos(x)
print sc.tan(x)

# complex value
x=sc.pi/6 + 2j
print sc.exp(x)
print sc.sin(x)
print sc.cos(x)
print sc.tan(x)

# array value
x=sc.array([0,sc.pi/6,2*sc.pi/6,3*sc.pi/6])
print sc.exp(x)
print sc.sin(x)
print sc.cos(x)
print sc.tan(x)
//@@@
1.68809179496
0.5
0.866025403784
0.57735026919
(-0.702494060276+1.53497752541j)
(1.88109784554+3.14095324918j)
(3.25815704249-1.81343020392j)
(0.0311427701606+0.981361072387j)
[ 1.          1.68809179  2.84965391  4.81047738]
[ 0.         0.5        0.8660254  1.       ]
[  1.00000000e+00   8.66025404e-01   5.00000000e-01   6.12323400e-17]
[  0.00000000e+00   5.77350269e-01   1.73205081e+00   1.63312394e+16]


Python scipy package includes numpy. The scipy package provide almost every numerical functions that many engineers/scientists use. You can do many calculations as if you use Matlab, more efficiently by SmartCnsl plugin.


//@@
import scipy as sy
import scipy.integrate as sl

print sl.quad(sy.sin, 0,sy.pi)
//@@@
(2.0, 2.2204460492503131e-14)


sympy package can operates symbolic equations e.g.symbolic differentials.


//@@
import sympy as ts
x,y,z = ts.symbols('xyz')

print ts.diff(1/(x+y)**2, x)
//@@@
-2/(x + y)**3


scipy.integrate.odeint solves ordinary differential equations. For example we solve s^2-2s+26 system represented by Laplace transformation which was unstable. pylab package can draw this oscillating graphs.


//@@
import scipy as sy
import scipy.integrate as si
def f(x,t):
    #return [ 0 if x[0]>1 and x[1]>0 else 0 if x[0]<-1 and x[1]<0 else x[1],
    return [                                                          x[1],
             2*x[1]-26*x[0] ] 

y = si.odeint( f, [0.01, 0], sy.linspace(0,10, 256) )

import pylab as pb
pb.plot(y[:,0])
pb.show()
//@@@


pylab package can draw many type graphs including 3d.


//@@
# this source is in ;;http://www.scipy.org/Cookbook/Matplotlib/mplot3D
from numpy import *
import pylab as p
#import matplotlib.axes3d as p3
import mpl_toolkits.mplot3d.axes3d as p3

# u and v are parametric variables.
# u is an array from 0 to 2*pi, with 100 elements
u=r_[0:2*pi:100j]
# v is an array from 0 to 2*pi, with 100 elements
v=r_[0:pi:100j]
# x, y, and z are the coordinates of the points for ing
# each is arranged in a 100x100 array
x=10*outer(cos(u),sin(v))
y=10*outer(sin(u),sin(v))
z=10*outer(ones(size(u)),cos(v))

fig=p.figure()
ax = p3.Axes3D(fig)
ax.plot_wireframe(x,y,z)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
p.show()
//@@@

Calculations by SmartCnsl and Python 1/2


Using SmartCnsl plugin and Python packages, you can easily solve many problems because Python includes powerful batteries:numpy,scipy,vpython, pylab, etc.


Adding Python Sf library, expressions become more similar to usual mathematical one. Optimally customizing Python sf for each aplication field, you could solve a problem by one liners for more than 90 percent. But I will explain Python sf in the next article. In this article, I explain calculations within the bound of Python

------------------------------------------
----------- numpy package ----------------
------------------------------------------


numpy is a Python package for vector/matrix. numpy is a very big package that include almost every classes/functions for vector/matrix.


Using SmartConsole plugin for Editra editor, You can execute Python block code between //@@ and //@@@ string by below operations

  • move cursor between //@@ and //@@@
  • execute menu:pysf(P) –> Y execute Python block(Y)


SmartCnsl plugin create a temp.py file in current directory and execute &quote;python -u -m temp&quote; in BackGrounder console window.


The result can paste in the text by menu:pysf(P) –> P paste results(P) operation.


Hereafter I will write only texts as below and will not show images.


//@@
import numpy as sc; print sc.info(sc)
#don't do the below expression. It print out 80000 lines
#;;import numpy as sc;help(sc) # 
//@@@
NumPy
=====

Provides
  1. An array object of arbitrary homogeneous items
  2. Fast mathematical operations over arrays
  3. Linear Algebra, Fourier Transforms, Random Number Generation

How to use the documentation
----------------------------
Documentation is available in two forms: docstrings provided
with the code, and a loose standing reference guide, available from
`the NumPy homepage `_.

We recommend exploring the docstrings using
`IPython `_, an advanced Python shell with
TAB-completion and introspection capabilities.  See below for further
instructions.

The docstring examples assume that `numpy` has been imported as `np`::

  >>> import numpy as np

Code snippets are indicated by three greater-than signs::

  >>> x = x + 1

Use the built-in ``help`` function to view a function's docstring::

  >>> help(np.sort)

For some objects, ``np.info(obj)`` may provide additional help.  This is
particularly true if you see the line "Help on ufunc object:" at the top
of the help() page.  Ufuncs are implemented in C, not Python, for speed.
The native Python help() does not know how to view their help, but our
np.info() function does.

To search for documents containing a keyword, do::

  >>> np.lookfor('keyword')

General-purpose documents like a glossary and help on the basic concepts
of numpy are available under the ``doc`` sub-module::

  >>> from numpy import doc
  >>> help(doc)

Available subpackages
---------------------
doc
    Topical documentation on broadcasting, indexing, etc.
lib
    Basic functions used by several sub-packages.
random
    Core Random Tools
linalg
    Core Linear Algebra Tools
fft
    Core FFT routines
polynomial
    Polynomial tools
testing
    Numpy testing tools
f2py
    Fortran to Python Interface Generator.
distutils
    Enhancements to distutils with support for
    Fortran compilers support and more.

Utilities
---------
test
    Run numpy unittests
show_config
    Show numpy build configuration
dual
    Overwrite certain functions with high-performance Scipy tools
matlib
    Make everything matrices.
__version__
    Numpy version string







You can see information of sub-packages as below.


//@@
import numpy as sc; sc.info(sc.linalg)
//@@@

Core Linear Algebra Tools
-------------------------
Linear algebra basics:

- norm            Vector or matrix norm
- inv             Inverse of a square matrix
- solve           Solve a linear system of equations
- det             Determinant of a square matrix
- lstsq           Solve linear least-squares problem
- pinv            Pseudo-inverse (Moore-Penrose) calculated using a singular
                  value decomposition
- matrix_power    Integer power of a square matrix

Eigenvalues and decompositions:

- eig             Eigenvalues and vectors of a square matrix
- eigh            Eigenvalues and eigenvectors of a Hermitian matrix
- eigvals         Eigenvalues of a square matrix
- eigvalsh        Eigenvalues of a Hermitian matrix
- qr              QR decomposition of a matrix
- svd             Singular value decomposition of a matrix
- cholesky        Cholesky decomposition of a matrix

Tensor operations:

- tensorsolve     Solve a linear tensor equation
- tensorinv       Calculate an inverse of a tensor

Exceptions:

- LinAlgError     Indicates a failed linear algebra operation






Get more information about numpy, it’s sub-pacages, each function/clsss using import numpy as sc; sc.info(sc.xxxx). Test calcuculations using thier functions/classes. For example


//@@
import numpy as sc; sc.info(sc.linalg.tensorinv)
import numpy as sc; sc.info(sc.linalg.norm)
import numpy as sc; sc.info(sc.random)
//@@@
------------------------------------------
----------- scipy package ----------------
------------------------------------------


scipy includes numpy. scipy is very,very big pacage. scipy is near to Matlab. It is almost impossible for one man to know all of scipy.


//@@
import scipy; scipy.info(scipy)
//@@@

SciPy: A scientific computing package for Python
================================================

Documentation is available in the docstrings and
online at http://docs.scipy.org.

Contents
--------
SciPy imports all the functions from the NumPy namespace, and in
addition provides:

Subpackages
-----------
::

 odr                          --- Orthogonal Distance Regression [*]
 misc                         --- Various utilities that don't have
                                  another home.
 cluster                      --- Vector Quantization / Kmeans [*]
 fftpack                      --- Discrete Fourier Transform algorithms
                                  [*]
 io                           --- Data input and output [*]
 sparse.linalg.eigen.lobpcg   --- Locally Optimal Block Preconditioned
                                  Conjugate Gradient Method (LOBPCG) [*]
 special                      --- Airy Functions [*]
 lib.blas                     --- Wrappers to BLAS library [*]
 sparse.linalg.eigen          --- Sparse Eigenvalue Solvers [*]
 stats                        --- Statistical Functions [*]
 lib                          --- Python wrappers to external libraries
                                  [*]
 lib.lapack                   --- Wrappers to LAPACK library [*]
 maxentropy                   --- Routines for fitting maximum entropy
                                  models [*]
 integrate                    --- Integration routines [*]
 ndimage                      --- n-dimensional image package [*]
 linalg                       --- Linear algebra routines [*]
 spatial                      --- Spatial data structures and algorithms
                                  [*]
 interpolate                  --- Interpolation Tools [*]
 sparse.linalg                --- Sparse Linear Algebra [*]
 sparse.linalg.dsolve.umfpack --- :Interface to the UMFPACK library: [*]
 sparse.linalg.dsolve         --- Linear Solvers [*]
 optimize                     --- Optimization Tools [*]
 sparse.linalg.eigen.arpack   --- Eigenvalue solver using iterative
                                  methods. [*]
 signal                       --- Signal Processing Tools [*]
 sparse                       --- Sparse Matrices [*]

 [*] - using a package requires explicit import

Global symbols from subpackages
-------------------------------
::

 misc                  --> info, factorial, factorial2, factorialk,
                           comb, who, lena, central_diff_weights,
                           derivative, pade, source
 fftpack               --> fft, fftn, fft2, ifft, ifft2, ifftn,
                           fftshift, ifftshift, fftfreq
 stats                 --> find_repeats
 linalg.dsolve.umfpack --> UmfpackContext

Release Editra plugin:SmartCnsl Ver0.0.1

In your texts, SmartCnsl links any files, launches any commands, compile and executes any codes. SmartCnsl might be used as a launcher or an IDE without using a mouse. If you combine SmartCnsl and Python sf, then you can calculate almost every expressions. It makes you enable to execute, link or calculate on your normal text data by 2 key strokes.

------------------------------------------
----------- History and Why --------------
------------------------------------------

Editra is a cool editor

  • open source
  • written with Python inheriting Scintilla
  • multi-platform:Window, Linux, Mac

On the other side, I has been using SmartCnsl plugin in Wz editor which was a Japanese minor editor and stopped to newly develop and for Windows only. SmartCnsl plugin is so useful that I can’t use other editors.

I decided to transplant SmarCnsl plugin for Editra. And I release the first version:SmartCnsl ver 0.0.1.

You can download SmatCnsl plugin hear:
http://www.nasuinfo.or.jp/FreeSpace/kenji/downloadE.htm

-----------------------------------------------
----------- SmartCnsl Usage -------------------
-----------------------------------------------

SmartCnsl plugin executes a text or texts as a OS command or program codes.

---- example 1: Menu: pysf --> A ----
-------- execute command ------------

#;;copy D:\utl\Editra\kcnsl\kcnsl\__init__.py D:\utl\Editra\kcnsl\kcnsl\__init__Py.bak /y

Sometimes I need to copy some program files before newly editing them without going to the directory where there are the files. And the full path string of the directory is too long. I can’t type the string without typo. So I write down the full path string in the last line of the program file in advance. When I need to copy the file, I move the cursor to end for the string of the copy command, and select a menu in Editra:pysf –> A execute. Operation: &quote;moving cursor and alt+p –> A&quote; made the backup file without changing my hand on a keyboard to a mouse.

---- example 2: Menu: pysf --> F ----
---- launch IE and load URL ---------

c:\"Program Files\Internet Explorer\IEXPLORE.EXE" http://www.nhk.or.jp/nhkworld/english/radio/program/index.html

My regular browser is Firefox. But some web sites force me to use IE. So I write down the URLs with the full path string of IE in a launching text. So I can reach the URL via SmartCnsl plugin. It is more rapid and easy than a mouse operation starting IE, copying and pasting the URL.

---- example 3: Menu: pysf --> F ----
---- start appropriate program associated with file extensions

girlCat1;;E:\work\cat_lib252057.jpg## a sexially pretty female cat
girlCat2;; ....

If you write strings in a text, then the text is a linked data too. You can see the image with an 2 stroke key operation:pysf menu –> F

You don’t need launch any viewer software. OS will select a appropriate viewer associated with a file extension:jpg, and display the jpg file in it.

This operation is applicable widely because you can use any kinds of file that is associated in your OS. You can use gif, mp3, URL, etc.

Another important usage is a link in program codes. You can write URL in your program comments. The URL might be a link to a place where original source was uploaded or to a position of a detailed document. You can go there with 2 key strokes menue:pysf:alt+p –> F.

---- example 4: Menu: pysf --> Y ----
---- execute python block codes -----

Move cursor to a position between string:”//@@” and “//@@@ where you write down python codes, and operate menu:pysf –> Y, then SmartCnsl plugin

  1. make temp.py file in current directory
  2. copy strings between //@@ and //@@@ to temp.py
  3. execute command “python -u -m temp”

//@@
import numpy as sc

v1,v2 = sc.array([1,2,3]), sc.array([4,5,6])

print v1 + v2           # vector sum
print sc.dot(v1,v2)     # inner product
print sc.cross(v1,v2)   # inner product
print sc.sin(v1)
//@@@
[5 7 9] 
32
[-3  6 -3]
[ 0.84147098  0.90929743  0.14112001]

You can paste the results in a console window by an operation:menu pysf –> P

You might be given to write many small Python codes because Python includes batteries. And you might not able to manage the many python files.

If you use SmartCnsl plugin, you can lap up all small codes blocks between //@@ and //@@@ in a single file which may have many linkable strings by SamarCnsl plugin.

---- example 5: Menu: pysf --> E ----
---- execute any compiler for block codes -----

You can use any compiler for you block cods by adding compile related commands as below


//@@
import Control.Monad
answers = do
--  a <- [1..9]
    a <- [0..9]
    b <- [0..9]
    c <- [0..9]
    let number = a*100+b*10+c
    if number == (a+b+c)*11 then return number else mzero
main = do print $ answers
//@@@
//copy #####.### temp.hs /y
//C:\lng\ghc6121\bin\runghc.exe temp.hs

[198]

After menu:pysf --> E operation, SmartCnsl plugin makes a file which name is #####.### than includes string between //@@ and //@@@. Then SmartCnsl executes command strings which are started with "//". SmartCnsl ends continuous execution of command if it has find a string that dosen't start with "//"

You can write any commands there, so you can does any things that computer can do. You can use any compiler/interpreter with SmartCnsl plugin. You might not need set environment variables because you can write full path commands.

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!