[sage-devel] Overloading Symbols with Cython

2009-04-02 Thread Chris Swierczewski

Is there a way to overload or redirect from symbols in a compiled
library to a Cython function?

I have a library containing several functions each, of course, with
their own corresponding symbol in the library symbol table. The main
function in the library internally calls each of the other auxiliary
functions within the library. I'm looking for some way to reroute one
of those function symbols to point to a custom Cython function,
essentially overriding whatever was contained in the library, so that
when the main function calls the function, foo(), it's the custom
Cython version and not the one contained in the library.

The library in question contains compiled Fortran code from the
Clawpack (www.clawpack.org) software project. The code is meant to be
used directly to perform computations. That is, the main function
calls a collection of auxiliary Fortran subroutines. Initially, these
subroutines are empty. It's up to the user to write their own code to
define the behavior of the subroutine.

If this is possible, it would probably the easiest way to my knowledge
to create a Cython wrapper of Clawpack.

Thanks in advance for any help or ideas offered!

--
Chris Swierczewski
cswie...@gmail.com
http://cswiercz.wordpress.com
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Overloading Symbols with Cython

2009-04-02 Thread Chris Swierczewski

Also, would Cython C API Declarations be another possible soution?

http://docs.cython.org/docs/external_C_code.html?highlight=compile#c-api-declarations

--
Chris
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Overloading Symbols with Cython

2009-04-02 Thread Chris Swierczewski

Robert,

> So I understand you better, what you're trying to do is let the user
> provide their functions at runtime rather than at compile time?

Yes.

> I think the easiest way to go about this would be to provide custom non-
> empty functions that call your code (e.g. via a function pointer the
> way callbacks work) rather than compiling empty stub functions and
> trying to overload the symbols at (load/run)time.

However (and perhaps my lack of effectively communicating is at fault)
the Fortran functions in the compiled library already call each other.
One thing I can do, however, is wrap these original Fortran functions
with C by adding some wrappers of each said function. The function
wrappers optionally accept function pointers. If it's a null pointer
than call the built-in Fortran function (most of which are already
stubs). However, any non-null function pointer is called in place of
the Fortran.

That's me thinking aloud. Does it sound like a good plan?

I can't really change the organization of the Fortran subroutines in
question since Clawpack users directly use and modify the code. Don't
want to mess with the core functionality.

--
Chris
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Suggested Sageclaw Output Directory

2009-04-14 Thread Chris Swierczewski

Hello,

I'm creating a Sage wrapper for a numerics package called Clawpack.
Clawpack works like so: when a user compiles their custom subroutines
against a library an executable is produced as output. The executable
then uses information stored in two, possibly more text files called
claw.data and setprob.data that must be located in the same directory.
That is, there are three files:

xclaw - the executable
claw.data
setprob.data

Just to give a better picture as to what's going on, there are several
stub subroutines contained within the Clawpack library. They govern
things like what to do at each step in an iterative technique for
numerically solving a PDE or how to change the solution grid if the
user wishes to supply their own adaptive mesh refinement scheme. The
user supplies their own Fortran SUBROUTINEs and links them against the
library, thus overriding the stubs. Finally, there's a main file, a
Fortran PROGRAM, that links to the overloaded library. When run, it
takes in the information stored in the two local data files and
outputs the result.

My question is:
What would be a good directory to place these three files. (The
wrapper will generate them appropriately.) My first thought was
$SAGE_LOCAL/bin but these files are particular to each PDE problem a
user wishes to solve. Also, I don't want to put any non-executable
files in there. I don't know if $SAGE_ROOT/tmp has any special use. My
other thought, however, was to just dump the files in the wrapper
location $SAGE_ROOT/devel/sage/sage/numerical/clawpack.

Any suggestions? Again, the three files are quite temporary. The
wrapper compiles and immediately executes the program and doesn't
really need those particular files again.

Thanks for the help!

--
Chris Swierczewski
cswie...@gmail.com
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Suggested Sageclaw Output Directory

2009-04-14 Thread Chris Swierczewski

mabshoff,

> Since the user must be able to write those files dynamically as I
> understand you neither anywhere under $SAGE_LOCAL nor in devel/sage is
> an option since there you are not guaranteed to be able to write
> there. So you should create custom directories under SAGE_TMP and copy
> the binary in there. This will also assure that running clawpack isn't
> racy.

Right on. Thanks for the tip.

> No, aside from the permission problem: No crap in devel/sage :)

Got it. I'll keep that in mind! :)

--
Chris
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Doc Days

2008-03-06 Thread Chris Swierczewski

I'll be there. So far I've been doctest-ing various files in sage/
rings (ring.pyx, ideal.pyx, integer_ring.pyx). I'd like to see where
people want to see more detailed docstrings and doctests.

--
Chris Swierczewski

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Doc Days

2008-03-06 Thread Chris Swierczewski

On Mar 6, 3:06 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> Hey, you're local.  Want to meet at a coffee shop, e.g., one in
> Capitol Hill?

Sure thing! I'd like to get some Sage work done in the morning.
(Algebra study session in the mid-afternoon.) Are there any other
Seattle-ites out there who would like to join in on the festivities?

--
Chris Swierczewski
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: interact versus manipulate

2008-03-08 Thread Chris Swierczewski

+1 vivify (actually, make it +1 interact)

--
Chris Swierczewski
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: 4-color theorem

2008-05-22 Thread Chris Swierczewski

William and Sara,

A couple nights ago, since I couldn't fall asleep, I wrote up some
Sage code that
supposedly generates an n-coloring of a graph, assuming that one
exists.
I say "supposedly" since I haven't tested it extensively. However, it
did work with
a couple of examples.

How might I go about posting this code in case Sara's student would
like to look
at it?

Once my own thesis is done, I'm going to spend some time cleaning it
up and
positing it as a ticket for review. Current code simply solves a
system of
equations to produce the n-coloring. However, a future implementation
uses Grobner bases! Who would've thought?

--
Chris
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Wrapping C++ Classes in Cython

2008-07-15 Thread Chris Swierczewski

Hello,

I'm having a compile issue with wrapping a certain C++ class. I posted
on the cython-dev email list at codespeak, but I thought I'd try here
as well. Allow me to describe the situation first before stating the
issue.

The Situation: the opentick API is a collection of cross-platform,
cross-language libraries (and headers in the C++ flavor) for receiving
live streams of financial data. (See www.opentick.com) Among the
API/source languages available, there is a collection of
cross-platform C++ headers along with a static library. What is meant
by cross-platform? Well, depending on which platform you're using,
different parts of the code are called and different macro definitions
are made. For example, when compiling on a Linux system one must write

#define __LINUX

at the top of their code before calling the appropriate headers. Now,
the main class is defined in the following way:

class DLL_EXP OTClient:
{
   public:
   ...
}

When running in the windows environment (that is, if you #define
__WIN), DLL_EXP is set to "__declspec(dllexport)" which, to my
understanding, has to do with using .dll files for callbacks akin to
how twisted works. However, when compiling in the Linux environment,
(#define __LINUX) the definition of the macro is "empty". That is, at
some point before the definition of the class, we simply have

#define DLL_EXP

implying that no .dll calls need to be made.

My Question (Finally): How do I go about wrapping this C++ class with
this strange little define hanging around the class declaration?
Methinks I'm having compile issues precisely because of this addition.
I checked the Cython wiki and the Sage Wiki on wrapping C++ classes
and couldn't find anything that looked like this. Thank you very much
in advance for any help! (And thank you for such an awesome
technology!)

--
Chris Swierczewski
[EMAIL PROTECTED]
mobile: 253 2233721
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Wrapping C++ Classes in Cython

2008-07-16 Thread Chris Swierczewski

Joel,

> Do you have control of the CFLAGS that are passed to the compiler (presumably
> gcc) which compiles the cython generated code?  If so, you can use the -D
> switch to define the __LINUX identifier.

Yes. Just to clarify, I've been able to compile by setting this flag
and simply typing

opentick.pyx
-
cdef extern "OTClient.h":
ctypedef struct c_OTClient "OTClient":
pass

cdef class Opentick:
pass

opentick.pxd
-
cdef class Opentick:
pass

This works just fine. (Robert Bradshaw confirmed this.) However, the
moment I create an instance of the c_OTClient class:

opentick.pxd
-
cdef class Opentick:
cdef c_OTClient *otclient

I get this compile error even when passing "-D __LINUX" to the cython
compiler (#define __LINUX). Methinks this a problem with the fact that
this #define DLL_EXP thing is floating around there, even though it's
an empty definition. I'm wondering if I have to write out the entire
wrapping in order for this to work...hrm.

--
Chris
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: grant proposal season

2009-08-29 Thread Chris Swierczewski

sage-devel and Randy, (cc. Kyle Mandli)

> Chris is working on a Sage spkg interface so that it can be easily
> installed as an optional package.

This raises another licensing-related issue: Clawpack requires the
following libraries and Python packages (these requirements are,
unfortunately, not well documented yet):

gfortran
numpy
matplotlib
farbtastic (listed as GPL, possibly GPLv3)
hdf5 ("BSD-style")
h5py (BSD)

I'm not sure how farbtastic fits into Clawpack. The "v3" part may be
an issue... Also, since we've been using gfortran for most of our
compilation, I'm not sure yet how Sage's g95-based Fortran compiler
will fare...

Now for a development question: should I include automatic svn/hg/git
checkout and compilation of the above packages (those that aren't
already in Sage) in Clawpack's spkg-install script? Is that the
standard procedure for optional spkgs? I can of course include a "This
will download and install x, y, and z: [Y/n]" check during the install
process. Since it would all occur within the Sage shell then I don't
think it would be a bad idea. (That is, if wouldn't modify the user's
system, just the Sage system.) Thoughts? Suggestions?

Like Randy said, Clawpack 5.0 is undergoing major changes so that a
Sage spkg can be considered possible. This includes major changes in
the documentation and website!!! :) If you have any questions then
feel free to email me. (Or someone who knows more about Clawpack.)

--
Chris Swierczewski

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Polymake Status / Porta

2009-11-02 Thread Chris Swierczewski

Hello,

I see that in the past there was some interest in polymake. I'm
suddenly interested as well in the package and was wondering if anyone
out there had done any work on it since the most recent discussion in
the mailing list back in June:

http://groups.google.com/group/sage-devel/browse_thread/thread/2720927446e35cd1/3759590c6affdcdb?lnk=gst&q=polymake#3759590c6affdcdb

I tried installing the spkg on my local Sage install on sage.math and,
as expected there were errors. I can post those errors if anyone is
interested.

What I really need is the functionality in Porta. (http://www.iwr.uni-
heidelberg.de/groups/comopt/software/PORTA/) Porta is integrated into
Polymake. If there is an overwhelming request for someone to take
another stab at Polymake then I can certainly make an attempt.
Otherwise, I'll just see if I can write up a wrapper for Porta. Porta
is all executable binaries so, with the subprocess module, it
shouldn't be to difficult to wrap.

The above is just an FYI for anyone who's interested.

--
Chris Swierczewski
cswie...@gmail.com
http://www.cswiercz.info
--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Polymake Status / Porta

2009-11-02 Thread Chris Swierczewski

Hello Marshall,

> I am not aware of anything that Porta could do that cddlib cannot do.
> The polyhedra.py package in geometry should be able to do all that.
> Please let me know if there is something you want to do that isn't
> covered by that.

I mainly wanted to use Porta's "system of ineqalities" <---> "set of
vertices of polytopes" conversion tool. I was going to use that
functionality to compute the convex hull (and various relaxations) of
stable sets of graphs.

> Recently Volker Braun did a massive rewrite of polyhedra.py, which
> should make it easier to improve and extend and fix some bugs.  I am
> currently adding some doctests and tweaking a few things to improve
> the backwards-compatibility and speed of his implementation; hopefully
> that can be finished up fairly soon (i.e. in the next month) and get
> into sage-4.2.1 or whatever the next release after that is. That's
> being tracked at http://trac.sagemath.org/sage_trac/ticket/7109 if you
> are interested.

Great! I look forward to news on it's completion. I just signed up to
be cc'ed on the Trac ticket. However, for the project I'm working on I
need something quick and dirty going right now. (One month is a bit
too long.) Porta seems easy to work with so I'll make an interface for
myself. If anyone is interested then I'll share with the devel
community.

--
Chris

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Polymake Status / Porta

2009-11-02 Thread Chris Swierczewski

> Well, the current polyhedra.py should work fine for that.  For
> example, if you have inequalities defining a unit cube x >= 0, y>=0,
> z>=0, x<=1, y<=1, z<=1, you could put them into sage as follows and
> get the vertices:

Interesting. I though that you needed a working install of the
polymake spkg in order for that stuff to work. (I saw a lot of "#
optional" doctests but didn't try the examples directly.) I'll take a
look tonight and let you know if that's what I need to get going.

--
Chris

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Misleading Instructions on the Windows Downloads Site

2010-10-20 Thread Chris Swierczewski
This is not a question about "how to download Sage on Windows".
Rather, I just wanted to point out an issue with the Windows Download
+ Instructions page

http://www.sagemath.org/download-windows.html

Under the "Usage" section it says that you'll need either VirtualBox
or VMWare Player. However, nowhere in the "additional instructions"
link of step 2 is VirtualBox mentioned nor on the list of available
downloads page (for example from the global mirror)

hhttp://content.wuala.com/contents/phatsphere/edoras/sage-mirror/win/index.html

is there a VirtualBox file or instructions on what to do with it.
There's even a sentence "The current VirtualBox Image provides you
with an encapsulated and solid tested system and contains everything
and needs nearly no configuration." at the end of the "Usage" section
but with no indication on where this is located.

Q: Am I missing something or is there really no documentation to go
with the VirtualBox installation?

--
Chris Swierczewski

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Website Feature Request: Public Examples Webpage / Workbook

2010-11-11 Thread Chris Swierczewski
A nifty service provided by some of the Ma* folks are webspaces where
users could upload some powerful research-level. For example:

* Mathematica: http://library.wolfram.com/
* Matlab: http://www.mathworks.com/matlabcentral/fileexchange/
* Maple: 
http://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet/cloud/overview

What's great about these websites is that the codes uploaded by users
aren't just demos of the software's basic functionality but cool uses
of the program to solve real problems. You can download them and try
them out yourself.

The Sage website has some similar resources on the Sage Feature Tour
page but these have more of a demo feel to them. Also, one would
probably need to contact the webmaster if they had a cool Sage
notebook to share that solves a cool and complicated problem. (For
example, once I finish implementing Riemann Theta function into Sage
I'll immediately start using them to generate quasiperiodic solutions
to KdV. These result in awesome pictures!)

Q: Does this sound like a good thing to have on the Sage website?

Q: How would such a service be implemented? I was thinking about a
public Sage Notebook of some sort. That way people can play with the
code in place. (Though, that raises the problem of preserving the
original code...hrm.)

Q: Is something like this already available and I just haven't ever
seen it before?

Again, this is just an idea that I think would be cool to see and at
the same time serve as good advertising for the awesome power of Sage.

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Website Feature Request: Public Examples Webpage / Workbook

2010-11-12 Thread Chris Swierczewski
> I really believe Sage needs to ship with a number of decent "published"
> examples. If one looks on any Sage server, one sees a list of published
> worksheets, many of which are either error messages, sometimes spam, and
> generally of very low quality.

Or worksheets related to mere homework problems, such as my own on the
UW Sagenb server.

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: new numerical developments in Sage ?

2011-01-02 Thread Chris Swierczewski
tdumont, 

> I am supposed to speak about numerics in Sage. I'll speak about what 
> exists nowadays, but I would like to know if there are  currently 
> projects, developments (if any), in this field of Numerical methods.
>

Sage includes the Numpy and Scipy packages, both of which perform numerical 
operations. (http://www.scipy.org/) You could check in with that community 
as well. They have several mailing lists as shown at 
http://www.scipy.org/Mailing_Lists.

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Advice for "Lazy" Symbolic Evaluation

2011-01-11 Thread Chris Swierczewski
Hello,

This question is about good / best practices for creating a "symbolic 
wrapper" for a purely numerical function.

I have a rather nice function that I've written as a class (with __call__ 
overloading, etc.) called RiemannTheta that at the moment can only handle 
numerical input. In particular, an instance of this class is a function, 
which I will call theta, from C^g --> C. This function can also numerically 
compute directional derivatives. For example, for g=3 I can compute the 
value of the first derivative in the [0,1,0] direction at the point [2,4,8] 
like so:

sage: theta = RiemannTheta(  )
sage: theta([2,4,8], derivs=[[0,1,0]])


What I would like to have is the ability to "lazily" evaluate symbolic 
expressions like:

sage: f = theta([x,x^2,x^3])

So that

sage: f(x=2) == theta([2,4,8])
True

I also want to be able to write

sage: f010 = theta([x,x^2,x^3], derivs=[0,1,0])
sage: f010(x=2) == theta([2,4,8], derivs=[[0,1,0]])
True

and I want to write a RiemannTheta.derivative(x) that will compute the 
symbolic derivative via the chain rule for vector to scalar-valued 
functions. Again, the key issue here is that *theta can only accept 
numerical input. *
*
*
So *my main question is*: what would be a / the Pythonic or Sage-thonic 
approach to appending this kind of behavior? The first step would be to 
detect symbolic expression input in RiemannTheta.__call__(). (In such a way 
that it's as fast as possible.) My thoughts were to create a new class, 
RiemannTheta_symbolic, with a RiemannTheta object stored as an attribute. 
There would be a layer of lazy symbolic expression handling to make it such 
that RiemannTheta isn't called until all unknown variables are given complex 
subs. I'm afraid to inherit anything in sage.symbolic (or whatever is 
relevant in this case) since it seems rather complicated. (But I'm willing 
to dive into it if necessary.)

Thanks for any insight or information.

--
Chris Swierczewski

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-11 Thread Chris Swierczewski
Do you mean, for example, how sin and cos handle inputs from the symbolic ring?

--
Chris Swierczewski
cswie...@amath.washington.edu
http://www.cswiercz.info

On Jan 11, 2011, at 12:07 PM, koffie  wrote:

> Sage uses symbolic ring fot this. I guess you should just look how the
> following is implemented and copy that disign:
>
> sage: var('x')
> x
> sage: f=sin(x^2)
> sage: f(x=2)
> sin(4)
> sage: f
> sin(x^2)
> sage: f.derivative()(x=2)
> 4*cos(4)
> sage: f.derivative(7)
> -128*x^7*cos(x^2) - 1344*x^5*sin(x^2) + 3360*x^3*cos(x^2) +
> 1680*x*sin(x^2)
>
> --
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-11 Thread Chris Swierczewski
> By the way, the sinus was a bad example since that uses ginac as a
> backend. You should look at the cotangent (i.e. Function_cot ).

Thank you very much for the insight!

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-14 Thread Chris Swierczewski
Does anyone know of an example where a class __call__ method takes lists as 
input? (With possible symbolic entries, of course.) I'm attempting to follow 
the structure of Function_sec (and similar functions) but when I try

sage: var('x')
sage: theta([x,x^2,x^3])

I get the following error:

Traceback (click to the left of this block for traceback)
...
TypeError: descriptor '__call__' requires a
'sage.symbolic.function.Function' object but received a 'list'


So for some reason my function isn't handling the symbolic input. Could 
somebody give some further guidance? Maybe a toy function that accepts vector 
input?


Thanks, 

Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-18 Thread Chris Swierczewski
> Try map instead: map(theta,[x,x^2,x^3]), because map applies the
> function
> to every list element.

Thanks for the suggestion but theta is, in fact, a vector-valued function. It 
acts on the elements of the input list / vector in a non-linear and non-trivial 
way. So I'm looking for ways to craete a function (perhaps wrapping 
BuiltinFunction) that can recognize and evaluate vectors over SR. 

The issue is that theta currently can only evaluate numerical input. (Over 
ComplexField.) There's a lot of numerical approximation going on so simply 
feeding it symbolic types isn't going to work. Hence, the need for some sort of 
wrapper around this numerical theta that will deal with symbolic input 
appropriately.

--
Chris



-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-18 Thread Chris Swierczewski
> Coercion is currently still a little problem, and I think you would
> earn some credits here if add this ability to the call method in
> BuiltinFunction. Have you ever looked into that class? Perhaps it
> helps you understanding the problem.

So I've been looking at some of the trigonometric functions in 
sage/functions/trig.pyx but I'm having trouble understanding what's going on. 
There's not much going on in terms of documentation and __call__ isn't even 
being overloaded in those examples. (See arccos or something similar.)

Have you encountered any slight more elaborate examples?

> If you need a quick solution, simply writing a small python class
> would do the trick. (similar as in the current ortho_polys version)

I considered this at first but I wanted to see if there's a preexisting Sage 
construct that could help me out. BuiltinFunction seems like a step in the 
right direction if I can only find examples of its use. There's not a lot of 
helpful documentation out there. I'm gonna have to make a blog post about it 
once I figure it out. :)

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-18 Thread Chris Swierczewski
> ...
> But as mentioned above: to understand BuiltinFunction, you should
> understand how the base class is working (at least the basics).

Thank you very much for the in-depth response! I look forward to taking a look 
at that trac ticket.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Advice for "Lazy" Symbolic Evaluation

2011-01-21 Thread Chris Swierczewski
Wohoo! I figured it out! I think this experience warrants writing a blog 
post.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Suggestions for Puiseux Expansion Implementation Location

2011-04-30 Thread Chris Swierczewski
Hello,

I recently implemented Puiseux series expansions in Sage and I would like to 
make this available in Sage to everyone. However, I was hoping for some 
suggestions as to where to place this code before I go any further.

First of all, Puiseux series 
(wiki<http://en.wikipedia.org/wiki/Puiseux_series>) 
are power series that allow for fractional exponents. They're useful in the 
theory of algebraic curves. On a smooth point on a (complex) algebraic curve 
f(x,y)=0 we can represent y=y(x) locally by a power series. We cannot 
represent y(x) as a power series at a branch point / singular point of the 
curve but we can do so with a, or several, Puiseux series.

These local representations have applications in computing integral bases 
and the basis of the cohomology of the Riemann surface corresponding to the 
algebraic curve. These, amongst other applications, are things that I'm 
working on implementing into Sage for my research.

I'm interested in Puiseux expansions only for algebraic curve so one 
possible location for this code is as a method under s
age.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular. 
When 
constructing a multi-
variate polynomial over QQ[x,y] using PolynomialRing or when taking a 
symbolic expression in two variables and using the 
Expression.polynomial() method this is the type received in return.

Another possibility is just writing puiseux as a module-level function. 
Suggestions as to where to place this is welcome.

--
Chris Swierczewski
University of Washington
Department of Applied Mathematics
http://www.cswiercz.info

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Puiseux Series Implementation Location

2011-04-30 Thread Chris Swierczewski
Hello,

I recently implemented Puiseux series expansions in Sage and I would like to 
make this available in Sage to everyone. However, I was hoping for some 
suggestions as to where to place this code before I go any further.

First of all, Puiseux series 
(wiki<http://en.wikipedia.org/wiki/Puiseux_series>) 
are power series that allow for fractional exponents. They're useful in the 
theory of algebraic curves. On a smooth point on a (complex) algebraic curve 
f(x,y)=0 we can represent y=y(x) locally by a power series. We cannot 
represent y(x) as a power series at a branch point / singular point of the 
curve but we can do so with a, or several, Puiseux series.

These local representations have applications in computing integral bases 
and the basis of the cohomology of the Riemann surface corresponding to the 
algebraic curve. These, amongst other applications, are things that I'm 
working on implementing into Sage for my research.

I'm interested in Puiseux expansions only for algebraic curve so one 
possible location for this code is as a method under s
age.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular. 
When 
constructing a multi-
variate polynomial over QQ[x,y] using PolynomialRing or when taking a 
symbolic expression in two variables and using the 
Expression.polynomial() method this is the type received in return.

Another possibility is just writing puiseux as a module-level function. 
Suggestions as to where to place this is welcome.

--
Chris Swierczewski
University of Washington
Department of Applied Mathematics
http://www.cswiercz.info

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Suggestions for Puiseux Expansion Implementation Location

2011-05-01 Thread Chris Swierczewski
Hello Marshall,

It would be great to have Puiseux series in Sage. 
>

I agree!
 

> Hierarchically it seems it might make sense as a seperate module in 
> rings/polynomial, just as laurent_series_ring.py.  It seems a little 
> categorically confusing (but perhaps convenient?) to add these as a 
> method to polynomials. 
>

Sounds good. Currently I just do all of computations over SR; even to find 
the coefficients of the series! (This highly inefficient, I know. I'll be 
working on a smarter approach, eventually.) I've been tossing around the 
idea of creating a new "data type" so I'm glad that there's outside interest 
in this approach. Besides, it'll be a good opportunity for me to practice 
using Sage's coercion model.
 

> Are you reusing any of the Laurent series code for this?  My 
> impression (which might be out of date) is that Laurent series need to 
> be cleaned up and improved a bit before building anything on top of 
> them.
>

Given that I'm not as familiar with the coercion model as I'd like to be, 
I'll definitely begin with the Laurent series code. Though, in the interest 
of time (especially if Laurent needs improvement) I may just create a 
simplified version. Looks like this is getting messier than I thought. :)

I appreciate the feedback.

--
Chris Swierczewski

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Suggestions for Puiseux Expansion Implementation Location

2011-05-05 Thread Chris Swierczewski
I'll see what I can do. :)

I'm using Maple's implementation of Puiseux series to debug my code. A while 
ago my advisor wrote this implementation and has retained the rights to 
distributing his code. However, Maple is a rather cryptic language to me so 
at the moment I'm only checking output. :) I'll see what Magma has to say.

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Automated Downloading of Most Recent Version of Sage

2016-04-08 Thread Chris Swierczewski
I have written an sort of experimental package for Sage and I am currently 
using TravisCI to run my tests. Since TravisCI doesn't have an installation 
of Sage I decided to make downloading it a step in the travis.yml config, 
in particular, during the before_install step:

wget 
http://mirrors.mit.edu/sage/linux/64bit/sage-7.0-Ubuntu_12.04-x86_64.tar.bz2

However, with the release of sage-7.1 this link appears to be broken. At 
least, TravisCI reported failure on this step of the automated testing.

My question is: is there are better way to obtain a particular version or, 
at least, the most recent version of Sage or do I have to update my 
travis.yml script every time a new version of Sage comes out? Thanks in 
advance for any help on the matter.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: catch a "sagemath" DeprecationWarning

2016-04-08 Thread Chris Swierczewski


> I was expecting the following to catch the DeprecationWarning
>
> import warnings
>
> warnings.filterwarnings('error',category=DeprecationWarning)
> try:
> print (exp(x)*exp(3*x)).simplify_exp()   #example with exp function
> except DeprecationWarning:
> print 'MegBook.py say: exercise needs review!'
>
> but it does not. I still got
>
>
In Python the warning construct behaves a little differently. I think if 
you use the "catch_warnings" context manager you'll be able at least test 
if a warning occurred. See 
https://docs.python.org/2/library/warnings.html#testing-warnings for 
information. 

import warnings
with warnings.catch_warnings(record=True) as w:
#
# do some things here that may cause a warning
#
if len(w) > 0:
print 'A warning was thrown'

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Automated Downloading of Most Recent Version of Sage

2016-04-08 Thread Chris Swierczewski


> The easiest way is probably to poll one of
>
> https://raw.githubusercontent.com/sagemath/sage/master/src/sage/version.py
>
> https://raw.githubusercontent.com/sagemath/sage/master/src/bin/sage-version.sh
>
>
That's a cute trick. I'll try that out. Thanks!

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Re: how we develop sage

2016-04-14 Thread Chris Swierczewski
(Disclaimer: I haven't yet read this entire thread when writing my 
response.)

Chris -- who wrote abelfunctions -- is a Univ of Wash grad student I 
> know.  I recently ran into him and he told me that he had spent years 
> writing this package as a standard Python package depending on sympy 
> (mainly) and not Sage.  However, it was getting quite frustrating to 
> finish abelfunctions, due to him needing things that are in Sage (I 
> think things like interval arithmetic?).   He didn't want to develop 
> his code in a way that depended on Sage, because he wanted it to be 
> more widely available, and he clearly didn't see the value in having 
> the code packaged as part of Sage for only a few small things.This 
> is a great example of how our centralized monolithic approach is 
> overall not the best for the community at large. 
>
> I've cc'd Chris in case he wants to clarify this, since I might not 
> understand. 
>

I remember discussions of this "modularized Sage" proposal way back when I 
was an undergraduate so I don't think it's anything new. In fact, hearing 
William talk about these issues back then is, in part, what prompted me to 
design my Sage package the way I did.

That being said, I can only really comment on my own experience developing 
Abelfunctions (http://github.com/abelfunctions/ableufncitons). As William 
mentioned, I started writing Abelfunctions such that only depended on very 
common core Python packages. Anaconda is very popular in the applied 
mathematics community and many of the key scientific computing packages I 
needed (e.g. Numpy, Scipy, networkx) are included in Anaconda as well as in 
Sage. This design seemed like a good idea at the time since my code could 
reach as many people as possible.

However, I slowly realized that Sympy's limitations in *efficiently* 
performing exact arithmetic with polynomial roots would prevent me from 
completing my software. After attempting to basically write my own version 
of QQbar in Sympy I made the very difficult decision, after four+ years of 
my Ph.D. writing Sympy workarounds, to completely rewrite my code "using 
Sage". I'm glad I did even though it added time to my Ph.D. --- a very 
small amount of time compared to the amount wasted trying to get Sympy to 
do what I wanted. So I am definitely glad that something like Sage is 
around to provide those open source tools I needed.

I didn't pursue writing Abelfunctions into Sage or even making 
Abelfunctions an "optional" or "experimental" listed spkg for several 
reasons:

1. *It is still in very active development* --- My quick (read: several 
month) total rewrite of Abelfunctions to use Sage reintroduced bugs that I 
squashed in the Python version. This is somewhat evidenced in the GitHub 
issues page. Because I'm constantly fixing and adding things as I finish my 
thesis it seems bothersome to have to push a new spkg after every commit. 
(Sure, I can write a script to try and do that.)

2. *It is a niche product* --- The mathematical communities I work with 
know about Abelfunctions and they have spread the word of its existence to 
those who might be interested. That's great. But I never assumed that it 
should be a standard part of Sage. Sage already takes too much time to 
compile so why bloat it with something that <1% of Sage users would ever 
touch? (Though, my implementation of Puiseux series in Abelfunctions is now 
making it's way into the Sage codebase.)

3. *GitHub is my resume* --- Headhunters have seen that I write code. I 
doubt they scan trac.sagemath as much as they do GitHub. Being able to put 
my code up on GitHub has made it clearer to others and to myself what my 
contribution to the math community has been. Not that I'm against sharing 
in an open-source project but to have Abelfunctions Trac tickets buried in 
the mound of other Sage issues didn't seem like a clear way to get people 
to work on this small project at the time.

Overall, developing Abelfunctions as an "external" Sage package has been 
pretty effective. I have some minor complaints, including the fact that the 
standard "$ sage setup.py install" doesn't seem to work on all platforms 
and trying to get TravisCI to download and install Sage before being able 
to test my code is a bit of a pain. If people who want to use it are having 
trouble finding it then it's my fault, not Sage's, since I suck at 
advertising myself. (Writing this post about my own code was difficult 
enough.) I think if enough people write packages this way we will see what 
works and what doesn't thus putting the whole "let's refactor Sage to make 
it modular" into a more concrete setting.

--
Chris


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://grou

[sage-devel] Re: how we develop sage

2016-04-14 Thread Chris Swierczewski
I felt like writing this up:

https://gist.github.com/cswiercz/c632d920565a2da519b73bd2b79d7920

Please suggest improvements and corrections.

--
Chris

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Abelfunctions - Looking for New Package Manager / Owner

2016-09-21 Thread Chris Swierczewski

*I'm not sure if this is an appropriate topic for sage-devel but given that 
this concerns an "external Sage package" I will take a chance posting here. 
I will not be offended, or surprised, if mods delete this thread.*

I am looking for someone to take over the management, and perhaps even the 
development, of the Abelfunctions 
(https://github.com/abelfunctions/abelfunctions) Sage package. 
Abelfunctions is a library for computing with Abelian functions, Riemann 
surfaces, and algebraic curves. Most users have been downloading it for my 
implementation of the Riemann theta function but there are other 
algebreo-geometric capabilities that are of interest to people in that 
community. If this sounds like an interesting project to you I would be 
more than happy to give a developer-oriented walkthrough of the 
functionality and design of the code and be available to answer questions.

*At the very least*, I would like someone who knows the Sage package 
installation system well enough to assist with some issues that come up 
when uses try to install Abelfunctions. The package relies heavily on 
Cython which might be the source of these issues. There is some interesting 
discussion about it this 
thread: 
https://groups.google.com/forum/#!searchin/sage-devel/abelfunctions|sort:relevance/sage-devel/LIbAfzFWpOU/U0iGNqLlAgAJ
 
(Where abelfunctions is explicitly mentioned.)

To be clear, I'm not running from a sinking ship. Other than recent 
installation problems the package more or less works well. I'm just a 
little burnt out by the project and am no longer interested, at least in 
the near future, to spend any time on it. Any help is appreciated.

--
Chris

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Memory Leaks in #6371?

2011-12-14 Thread Chris Swierczewski
I've finished with an implementation of Riemann theta functions in Sage. 
(See patch #6371 .) 
Unfortunately, as shown at the bottom of the comment thread for #6371, my 
code seems to be introducing memory leaks. The culprit doctest failure is 
in sage/all.py:

sage: import gc 
sage: import inspect
sage: from sage import *
sage: frames=[x for x in gc.get_objects() if inspect.isframe(x)]
sage: len(frames)   
11 

(The output has changed from 11 to 26.)

So, I have a few questions. First, what does the above code actually do? 
I'm unfamiliar with the gc and inspect modules. Any references would be 
appreciated.

Second, what would be a good fix for this issue? I don't how how serious of 
an issue this is. In the comments thread I explain the class structure of 
my code . Any 
suggestions on how to improve that constructor code? I can't think of any 
other part of the code where I would introduce memory leaks. Would leaving 
this alone cause major performance issues with Sage?

Thank you for any suggestions.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Memory Leaks in #6371?

2011-12-14 Thread Chris Swierczewski


> Change your code so the actual Riemann theta module isn't imported
> until a users actually wants to use it (e.g. use lazy_import).  Then
> it won't trigger an issue with all.py at startup.  This is also
> generally a good idea to keep from further impacting Sage's startup
> time.
>

Thanks for the response. This looks like the best solution for now. I have 
some future optimizations I'd like to implement, anyway. I'll address that 
memory issue then.

--
Chris

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Chebfun

2014-05-30 Thread Chris Swierczewski

>
> What I find particularly interesting is that they went to OSS fairly 
> early, but of course it relies on proprietary underneath with Matlab; 
> they're open-sourcing everything they can, and of course Matlab is pretty 
> available compared to other programs
>

For my Master's project I wrote a toy Python implementation of Chebfuns 
called pychebfun. Haven't worked on it much since then but Olivier Verdier 
forked and continued that work. You can find his repo here:

https://github.com/olivierverdier/pychebfun

When Nick Trefethen visited UW AMath several years ago back when I was 
still playing around with pychebfun he seemed pretty interested in bringing 
chebfuns to the Python community. (Actually asked me to talk about my toy 
implementation at the ICIAM 2011 conference!) We also discussed a vision 
where there was a C/C++/FORTRAN (or whatever) core Chebfun library with 
Python and MATLAB front-ends. Perhaps pipe-dreamy at this point since 
MATLAB Chebfun is very mature at this point. Regardless, it's pretty 
powerful stuff, especially once you start talking about solving systems of 
differential equations. (Of course, the numerical optimization stuff is 
cool, too.)

--
Chris

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.