`double vg[3][3] = {{1,4,5},{4,2,6},{5,6,3}};`

I think this can be done by just implementing ccode._print_Matrix(). It will be called by ccode() whenever a sympy.matrices.matrices.Matrix object is encountered.
]]>The functionality you describe would be extremely cool! Perhaps it could be triggered by a keyword option, a la `symmetric=True`

, to the `IndexedBase`

object? I think that would be the appropriate place to store such an assumption. Then hopefully `get_contraction_structure()`

in the sympy.tensor.index_methods module can be improved so that it detects and reports contractions where such optimizations are possible. If this can be done, I believe it will be easy to implement the actual code printing. If you decide to go for it, it is a good idea to open a feature request on the issue tracker, to serve as a central place to discuss design ideas.

PS! I am not the author of the entire ccode, I just worked on it this summer to implement array printing, and some other stuff.

]]>i.e.

print ccode(A[i,j]*x[j]*exp(3), assign_to=y[i])

I was wondering why that works.

Also I noticed Matrices cannot be printed. I am somewhat interested in supporting this so it would be nice if you could give me some hints for adding that in. For example I would like to do something like the following.

double xi[] = {1,2,3,1,1,2};

double xj[] = {1,2,3,2,3,3};

for( l= 0;l < 6; l++)

for( j = 0; j < 3 ; j++)

C[l] += F[j][xi[l]]*F[j][xj[l]];

Where F is 3×3 matrix and C is symmetric and can be reduced to 6 entries using voigt notation. Likewise, calculating CC = C[i,j]*C[i,j] in your python notation can be done on voigt represented matrices as so:

double vg[3][3] = {{1,4,5},{4,2,6},{5,6,3}};

for ( i = 0;i<3; i++)

for( j=0; j<3 ; j++)

CC += C[vg[i][j]] * C[vg[i][j]];

As you are the author of ccode(?), what are your thoughts on modifying or adding to ccode such that ccode could generate what is shown above should you happen to know that C is a symmetric matrix apriori.

]]>Needed to install the dev version of python to get the file Python.h ]]>

I think your way of accelerating the calculation of symbolic expressions is exactly what I am looking for.

However, I do not seem to get the autowrap to work on my ubuntu maverick box.

I get the following error when trying to autowrap the linspace code:

In [9]: linspace = autowrap(Eq(x[i], linearmap))

—————————————————————————

CodeWrapError Traceback (most recent call last)

/home/bn/newpackages/python/sympy/ in ()

/home/bn/newpackages/python/sympy/sympy/utilities/autowrap.py in autowrap(expr, language, backend, tempdir, args, flags, verbose, helpers)

385 helps.append(Routine(name, expr, args))

386

–> 387 return code_wrapper.wrap_code(routine, helpers=helps)

388

389 def binary_function(symfunc, expr, **kwargs):

/home/bn/newpackages/python/sympy/sympy/utilities/autowrap.py in wrap_code(self, routine, helpers)

125 self._generate_code(routine, helpers)

126 self._prepare_files(routine)

–> 127 self._process_files(routine)

128 mod = __import__(self.module_name)

129 finally:

/home/bn/newpackages/python/sympy/sympy/utilities/autowrap.py in _process_files(self, routine)

149 if retcode:

150 raise CodeWrapError(

–> 151 “Error while executing command: %s” % ” “.join(command))

152

153 class DummyWrapper(CodeWrapper):

CodeWrapError: Error while executing command: f2py -m wrapper_module_0 -c wrapped_code_0.f90

Is there anything that can be repaired easily?

The same thing works on my mabook pro running 10.6.5