Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: What will scientific computing in Perl 6 look like?

by jettero (Monsignor)
on Jul 14, 2008 at 12:14 UTC ( #697457=note: print w/ replies, xml ) Need Help??


in reply to Re: What will scientific computing in Perl 6 look like?
in thread What will scientific computing in Perl 6 look like?

By the way complex numbers are natively supported in Perl 6.

Can you construct arbitrary vector spaces (e.g., the quadratics) or are the complex numbers a special case?

UPDATE: I think abstract algebra starts at the undergrad level. Also, wow, perl6 is like a whole new language.

-Paul


Comment on Re^2: What will scientific computing in Perl 6 look like?
Re^3: What will scientific computing in Perl 6 look like?
by moritz (Cardinal) on Jul 14, 2008 at 12:22 UTC
    Complex numbers are special cased, in that they are explicitly specced. While numerics aren't a weak spot in Perl 6, they aren't exactly the most powerful area either (Larry keeps telling us on #perl6 that he doesn't do higher mathematics ;-)

    But it's quite easy to define your own data types and the associated operations:

    # suppose you inherit from List to implement your vector: class MyVector is List { sub infix:<+>(MyVector @self, MyVector @other) is export { return @self + @other; } # adding a scalar: sub infix:<+>(MyVector @self, Num $other) is export { return @self + $other } }

    No more hassle of overloading literal constants in the source, since multi method dispatch takes care of it all.

      I simply don't believe that multi method dispatch takes care of it all when it comes to different number systems. While Perl 6 offers a lot of features, to the best of my knowledge The Structure of Computer Programming is still correct when it says "Developing a useful, general framework for expressing the relations among different types of entities (what philosophers call ``ontology'') seems intractably difficult. The main difference between the confusion that existed ten years ago and the confusion that exists now is that now a variety of inadequate ontological theories have been embodied in a plethora of correspondingly inadequate programming languages. For example, much of the complexity of object-oriented programming languages -- and the subtle and confusing differences among contemporary object-oriented languages -- centers on the treatment of generic operations on interrelated types."

      That is not to say that Perl 6 is not an improvement. It is. It just isn't a solution.

        Well, Perl 6's type system has difficulties with respect to numeric types, because they don't form a nice hierarchy. Luckily we have roles, and thus can have a type of all (scalar) numeric types without pressing them into a hierarchy.

        Implementing the numeric types correctly is a bit tricky, but the fact remains that the user (aka Perl 6 programmer) can simply add (or override) operators for each pair of types. If one of them is always a user-defined one you can guarantee no clashes with existing semantics.

        So I don't see how Perl 6 isn't a solution wrt to adding new numeric types to the language - would you care to elaborate?

      Don't you need to use the multi keyword on those subs?
        It's better style, but if the prelude defines a proto infix:<+> (and I'm quite sure it does) it's redundant. Good catch anyway.
Re^3: What will scientific computing in Perl 6 look like?
by blazar (Canon) on Jul 20, 2008 at 10:12 UTC
    Can you construct arbitrary vector spaces (e.g., the quadratics) or are the complex numbers a special case?

    I personally believe that this is slightly nonsense, since vector spaces are "simply" vector spaces, while the complex numbers can be described in a variety of different algebraic structures: they're a field, a two dimensional real algebra, a one dimensional complex algebra, etc. Now, I'm sure that binary field operations will be supported for complex numbers: thus whether arbitrary vector spaces will be supported or not, it won't be a matter of "special case."

    --
    If you can't understand the incipit, then please check the IPB Campaign.
      It isn't nonsense at all. Subspaces, fields, and vector spaces are all interrelated. The complex numbers are a vector space and the quadratics are a subspace of them. I was hoping that instead of just complex numbers, you could use the special type for all sorts of vector math, tensors, quadratics, values with units attached. Why make complex numbers the special case? Why not have two tuples or n-tuples that know about co-efficients so you can do all kinds of interesting algebra in the same way you can use complex numbers.

      All you have to do to make this really really flexible is allow users to change the value of that sqrt(-1) co-efficient(s) and change the length of the vector/sum/value. Tada.

      UPDATE: Yes, well, I believe the quadratics are a 2-dimensional vector space and a field of reals. It happens to be a subspace of the complexes, so maybe it doesn't matter, but I fail to see why there couldn't be an interface to use the complex number system for more.

      -Paul

        I personally believe it is still a nonsense, wrt the "special case" (your literal words) bit: do not misunderstand me! I am too hoping that -to quote you verbatim- we "could use the special type for all sorts of vector math, tensors, quadratics, values with units attached." (And more!) Nevertheless, complex numbers are something more: i.e. a field, and that cannot be told of general n-dimensional vector spaces: given the confidence you talk about these topics, you certainly know that the only three real algebras (with division) are the reals themselves, the complex numbers and quaternions. (Then you have the more esoteric Cayley numbers, if you're willing to give up on associativity.) Or else, are you taking, say, two n-dimensional vectors and multiply them together?!? Certainly, you can have an inner product, but that's an entirely different beast, and not a generalization of complex multiplication. Thus, definitely, not as a "special case."

        --
        If you can't understand the incipit, then please check the IPB Campaign.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-08-28 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (253 votes), past polls