Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
XS is like another mini language. First you need a C compiler, actually you need the same compiler used to compile your Perl. So, on Linux is easy since is always with GCC, but on Win32 you will need Microsoft Visual C++ 6+ (not free) if you got Perl from Active State, or MingW, that is GCC for Win32.

Than you need to learn how Perl works with C and the resources for that (perlapi). So, take a look in the docs: perlapi, perlguts, perlxstut. All of that you can find better at http://www.perldoc.com.

If you already know C, I think that the best way to you make XS functions with Perl is getting as examaple the sub{C} methods that you can find in the sources of AI::NNEasy. Because this functions have a Perl and a C version, so you can compare them and understand better what the C macros does. Also the Class::HPLOO syntax is easy like sugar, since you only need to write the function, all the rest Class::HPLOO will write for you, converting to Inline::C, than Inline will convert to XS, and from XS is with Perl. So, the code below is 100% complete, you just need to have a C compiler well installed:

use Class::HPLOO ; class Foo { sub[C] int add( int x , int y ) { int ret = x + y ; return ret ; } }
Now you just need to run the code above, and the rest is automatically.

Other thing, your module is inside AI::NNEasy starting from the class AI::NNEasy::NN. So, if you move this class (and the sub classes sinde AI::NNEasy::NN::*) to your project you will have your modules with the resources that I have added to it. I let it separated to be more easy to you to get back the work that I did, so be free to use it. ;-P

Graciliano M. P.
"Creativity is the expression of liberty".


In reply to Re^4: AI::NNEasy to setup fast a Neural Network using just Perl and XS. by gmpassos
in thread AI::NNEasy to setup fast a Neural Network using just Perl and XS. by gmpassos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (12)
    As of 2014-10-02 17:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (68 votes), past polls