Hello,
My name is Zhiqi KANG, I am a 4th year undergraduate of a 5-year engineering institution: Université de Technologie de Compiègne, France. I am interested in the project Linear algebra: Tensor core.Here is the link for the description of project idea. https://github.com/sympy/sympy/wiki/GSoC-2019-Ideas#linear-algebra-tensor-core Even though I am not very familiar with the tensor in the physical field, its principal in the mathematical field is quite interesting. I have precisely looked at the requirement of this project and make sure that I am capable to accomplish most of its task. However, there are still many questions that I would like to discuss with all contributors of SymPy and expecially with the mentor. One urgent problem is that I don't find the name of mentor for this project, so I don't really know who I should CC. Could you please help me to find the mentor for this project?
Please review this draft proposal and tell me what to be ameliorated. Thank you!
Ø Better Algorithms for sparse array:
The idea is to manipulate directly les arrays in the sparse array level. Casting sparse arrays to a dense array and then operating is kind of a redundancy. I have found an example in tomatrix() function of sympy\sympy\tensor\array\sparse_ndim_array.py where we convert the sparse_array to a new dictionay and then cast it to matrix.(Code bellow)
But I cannot find more cases in the array/tensor module, it would be great if some one can help me find out where other cases are.
from sympy.matrices import SparseMatrix
if self.rank() != 2:
raise ValueError('Dimensions must be of size of 2')
mat_sparse = {}
for key, value in self._sparse_array.items():
mat_sparse[self._get_tuple_index(key)] = value
return SparseMatrix(self.shape[0], self.shape[1], mat_sparse)
Ø NumPy-like operations
We have now some operations for arrays in SymPy:
² arrayfy
² tensor product
² derivatives by array
² permute dimension
² contraction
For this part of project, I am planning to implement some operations such as:
² sum
² divide/multiply(element wise)
² any
² comparators(greater/less/equal)
² logical operator(and/or/not/xor)
² random
Ø lazy operators on arrays
lazy evaluation can improve the performance while iterating the array since it creates value only if it is called. To implement lazy operators, I am thinking about two plans:
1. Create a new sub-module named lazy-array (larray) of which most of the operations are lazy evaluated. A standard Array can be cast to a lazy-array by simply calling the constructor of larray and passing it as parameter. By doing so, users can choose whatever they want in the module level, which means that to manipulate a simple array or a lazy array.
1. Create a lazy version for les operators mentioned above. The lazy operators are accessible for a specific purpose. This implementation focusses on a function level for calling lazy evaluated operations, which means to call a simple inverse_matrix function or a lazy one.
Besides, I have found in sympy\sympy\tensor\tensor.py a class _TensorDataLazyEvaluator which can be an example for me to implement these functionalities. It has methods like delete item, inverse matrix, etc.
Ø code generation for arrays and array operators
This part of project should be involved with another GSoC project purely for code generation. I would like to discuss with the mentor of the codegen project to have a better point of view for it.
I have had an internship for 6 months in BNP Paribas Securities Services in Paris as developer. During this period, I have similarly worked on code generation task, except that the programming language is C#.( I was using EntityFramework and T4 by Microsoft) I believe that this experience can help me to get familiar with the code generation process in this project.
Ø Integration over indexed symbols and arrays
Firstly, I would like to talk about integration over arrays:
Can we imagine the array as a set of coordinates? Suppose that we have a array A, say 2-dimension as (p, q). We can image two axis x and y so that index i and j are coordinates for the point Pij in axis x and axis y. The value A[pi,qj] should be the coordinate of axis z. By assuming this, we can use a Riemann integral or Lebesgue integral to calculate its integration like summing the column in the 3D space.
I don’t know if this idea is correct, I would love to discuss it with you!
Secondly, for integration over indexed symbols, I don’t really know what it means. Should the output be an expression rather than a value? It would be great if someone can show me with an example, thanks!
Ø Equation solving with indexed symbols.
I am not very familiar with this topic either. Should the result be an expression as well? It would be great if someone can show me with an example, thanks!
Ø Implement some well-known tensor math
If the time permits, I would be glad to do the extra part of this project. But I don’t know very well relativity, electromagnetism, etc. It would take me some time to better understand the principles and start to work on it. However, I do find some math formula that associated with this topic. https://en.wikipedia.org/wiki/Integral
Ø Unify the various SymPy module
To be done.
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/a5ff49d3-63e4-45e5-b87f-4b9d6be30085%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Zhiqi,This looks well thought out a first glance. Check out https://github.com/sympy/sympy/wiki/GSoC-2019-Student-Instructions if you haven't yet.Jason
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sy...@googlegroups.com.
Hello Jason,Thank you! It seems that you are quite busy now greeting to the newbies. :-)I am waiting for someone to review my proposal. Could you please tell me to whom I should reach out?Regards,Zhiqi
在 2019年3月28日星期四 UTC+1下午5:14:46,Jason Moore写道:
Zhiqi,
To unsubscribe from this group and stop receiving emails from it, send an email to sy...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/a5ff49d3-63e4-45e5-b87f-4b9d6be30085%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/91ab9eee-afef-41fa-8b60-ea2b47fb074c%40googlegroups.com.
Ø lazy operators on arrays
lazy evaluation can improve the performance while iterating the array since it creates value only if it is called. To implement lazy operators, I am thinking about two plans:
1. Create a new sub-module named lazy-array (larray) of which most of the operations are lazy evaluated. A standard Array can be cast to a lazy-array by simply calling the constructor of larray and passing it as parameter. By doing so, users can choose whatever they want in the module level.
(Updated: a class diagram for Lazyarray.)
1. Create a lazy version for les operators mentioned above. The lazy operators are accessible for a specific purpose. This implementation focusses on a function level for calling lazy evaluated operations.
(Updated: a class diagram for the inner Lazyevaluation. Example brorrowed from Lazyevaluation)
(updated: analysis for this approaches)
Personnally I think the 1) approach is better because this implementation can enable a independency between the existing Array module and the LazyArray. It will also benefit the test and maintenance for the LazyArray. I suppose that the Lazyarray to Array should be as Numpy to List, Lazyarray should be seen as a toolkit.
But the disadvantage is that the mixte of standard Array and Lazyarray object may lead to some confusion.(e.g. Lazyarray.sum(Array()) should return a Lazyarray or Array object?) The problem can probably be solved by a convention like: afer casting an Array to Lazyarray, one would keep using Lazyarray. Of course if needed, the transformation from Lazyarray to Array should be provided at any time.
Besides, the Lazy-evaluation should be transparent to the users, so that we are supposed to keep the naming convention to operators as we have for Array.
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0e7b466b-538b-4689-964a-86d4f66cfc3a%40googlegroups.com.
class Lazyarray(object):"""Lazy-evaluated array"""def __init__(self, array):"""Initiate a Lazyarray with an array"""self.operations = []def evaluate(self, f=None):"""Evaluate all operations stored in the operations list.If parameter 'f'is None then evaluate all operations, otherwise evaluate only thefunction 'f'Some functions will use generator object for some iteration purposesin order to save the memory cost"""def _add_operation(self, op):"""Add an operation to the list of operations"""def sum():"""Add the operator Sum to the list of operations, transparent to the users"""def _sum()"""An inner function that will be called by evaluate() to perform a sum. Areal implementation of sum operator."""
There are two branches: indexed symbols (which do not contain components data), and array-like objects (containing component data).
One thing that worries me is that we shouldn't be reimplementing NumPy