R or Cpp for some finance work involved complex numbers?What programming languages are most commonly used in quantitative finance?Refer some most recent books of derivatives pricing by C++GBM in R giving negative numbers?

How did Ron get five hundred Chocolate Frog cards?

"Shake your head all you like" meaning

Why using babel with beamer produce warnings about rmfamily and ttfamily

How can demon technology be prevented from surpassing humans?

33 Months on Death Row

Which collation should I use for biblical Hebrew?

Can a character dodge an attack that beats their Armor Class?

Is it plausible that an interrupted Windows update can cause the motherboard to fail?

How to deal with intolerable behavior of a subordinate?

Do I need to explicitly handle negative numbers or zero when summing squared digits?

Shortest way to get an EOF Error

Delete line if next line is the same

Employer says he needs to delay payment by 3 months due to bureaucracy

Having trouble with accidentals - Note-for-note vs traditional?

Is it possible to cross Arctic Ocean on ski/kayak undetectable now?

Are There 3D Rules for Flying and Distance?

How can my hammerspace safely "decompress"?

Why are seats at the rear of a plane sometimes unavailable even though many other seats are available in the plane?

How to execute a project with two resources where you need three resources?

What are the consequences for downstream actors of redistributing a work under a wider CC license than the copyright holder authorized?

How to make a PCB based on ATtiny easily updatable by end users?

What is the purpose of the redundant "いい人" in this example sentence

Disrespectful employee going above my head and telling me what to do. I am his manager

Fill a bowl with alphabet soup



R or Cpp for some finance work involved complex numbers?


What programming languages are most commonly used in quantitative finance?Refer some most recent books of derivatives pricing by C++GBM in R giving negative numbers?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;

.everyonelovesstackoverflowposition:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;








3














$begingroup$


I need to implement some pricing functions which involve complex numbers. The equations involve various expressions such as $Re$ and $Img$ (i.e the real and imaginary part of the complex number), and I need to do some Fast Fourier Transforms and other things. Obviously the end result is always real, but the intermediate calculations are complex.



I have never used complex numbers before when I have programmed, so is there something particular I should be aware of? I want to use either R or C++: which would be more suitable for handling complex numbers? Are there any computational difficulties when dealing with complex numbers?










share|improve this question







New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$











  • 1




    $begingroup$
    A very warm welcome to Quant.SE! Thank you for question, please see my answer below.
    $endgroup$
    – vonjd
    7 hours ago










  • $begingroup$
    ...for "your" question, of course ;-)
    $endgroup$
    – vonjd
    5 hours ago


















3














$begingroup$


I need to implement some pricing functions which involve complex numbers. The equations involve various expressions such as $Re$ and $Img$ (i.e the real and imaginary part of the complex number), and I need to do some Fast Fourier Transforms and other things. Obviously the end result is always real, but the intermediate calculations are complex.



I have never used complex numbers before when I have programmed, so is there something particular I should be aware of? I want to use either R or C++: which would be more suitable for handling complex numbers? Are there any computational difficulties when dealing with complex numbers?










share|improve this question







New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$











  • 1




    $begingroup$
    A very warm welcome to Quant.SE! Thank you for question, please see my answer below.
    $endgroup$
    – vonjd
    7 hours ago










  • $begingroup$
    ...for "your" question, of course ;-)
    $endgroup$
    – vonjd
    5 hours ago














3












3








3


1



$begingroup$


I need to implement some pricing functions which involve complex numbers. The equations involve various expressions such as $Re$ and $Img$ (i.e the real and imaginary part of the complex number), and I need to do some Fast Fourier Transforms and other things. Obviously the end result is always real, but the intermediate calculations are complex.



I have never used complex numbers before when I have programmed, so is there something particular I should be aware of? I want to use either R or C++: which would be more suitable for handling complex numbers? Are there any computational difficulties when dealing with complex numbers?










share|improve this question







New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$




I need to implement some pricing functions which involve complex numbers. The equations involve various expressions such as $Re$ and $Img$ (i.e the real and imaginary part of the complex number), and I need to do some Fast Fourier Transforms and other things. Obviously the end result is always real, but the intermediate calculations are complex.



I have never used complex numbers before when I have programmed, so is there something particular I should be aware of? I want to use either R or C++: which would be more suitable for handling complex numbers? Are there any computational difficulties when dealing with complex numbers?







programming






share|improve this question







New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question



share|improve this question






New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









ToloponiAdionoToloponiAdiono

161 bronze badge




161 bronze badge




New contributor



ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




ToloponiAdiono is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 1




    $begingroup$
    A very warm welcome to Quant.SE! Thank you for question, please see my answer below.
    $endgroup$
    – vonjd
    7 hours ago










  • $begingroup$
    ...for "your" question, of course ;-)
    $endgroup$
    – vonjd
    5 hours ago













  • 1




    $begingroup$
    A very warm welcome to Quant.SE! Thank you for question, please see my answer below.
    $endgroup$
    – vonjd
    7 hours ago










  • $begingroup$
    ...for "your" question, of course ;-)
    $endgroup$
    – vonjd
    5 hours ago








1




1




$begingroup$
A very warm welcome to Quant.SE! Thank you for question, please see my answer below.
$endgroup$
– vonjd
7 hours ago




$begingroup$
A very warm welcome to Quant.SE! Thank you for question, please see my answer below.
$endgroup$
– vonjd
7 hours ago












$begingroup$
...for "your" question, of course ;-)
$endgroup$
– vonjd
5 hours ago





$begingroup$
...for "your" question, of course ;-)
$endgroup$
– vonjd
5 hours ago











1 Answer
1






active

oldest

votes


















3
















$begingroup$

Why choose? C++ is perfectly integrated into R via the excellent Rcpp package (on CRAN). And you can use complex numbers there too:



library(Rcpp)
cppFunction("ComplexVector doubleMe(ComplexVector x) return x+x; ")
doubleMe(1+1i)
## [1] 2+2i

doubleMe(c(1+1i, 2+2i))
## [1] 2+2i 4+4i


I would suggest starting out with R and if you run into performance problems, use C++ via Rcpp.



Just for reference, the same as above in Base R:



doubleMeR <- function(x) x+x 
doubleMeR(1+1i)
## [1] 2+2i

doubleMeR(c(1+1i, 2+2i))
## [1] 2+2i 4+4i





share|improve this answer












$endgroup$
















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "204"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );







    ToloponiAdiono is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fquant.stackexchange.com%2fquestions%2f49069%2fr-or-cpp-for-some-finance-work-involved-complex-numbers%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3
















    $begingroup$

    Why choose? C++ is perfectly integrated into R via the excellent Rcpp package (on CRAN). And you can use complex numbers there too:



    library(Rcpp)
    cppFunction("ComplexVector doubleMe(ComplexVector x) return x+x; ")
    doubleMe(1+1i)
    ## [1] 2+2i

    doubleMe(c(1+1i, 2+2i))
    ## [1] 2+2i 4+4i


    I would suggest starting out with R and if you run into performance problems, use C++ via Rcpp.



    Just for reference, the same as above in Base R:



    doubleMeR <- function(x) x+x 
    doubleMeR(1+1i)
    ## [1] 2+2i

    doubleMeR(c(1+1i, 2+2i))
    ## [1] 2+2i 4+4i





    share|improve this answer












    $endgroup$



















      3
















      $begingroup$

      Why choose? C++ is perfectly integrated into R via the excellent Rcpp package (on CRAN). And you can use complex numbers there too:



      library(Rcpp)
      cppFunction("ComplexVector doubleMe(ComplexVector x) return x+x; ")
      doubleMe(1+1i)
      ## [1] 2+2i

      doubleMe(c(1+1i, 2+2i))
      ## [1] 2+2i 4+4i


      I would suggest starting out with R and if you run into performance problems, use C++ via Rcpp.



      Just for reference, the same as above in Base R:



      doubleMeR <- function(x) x+x 
      doubleMeR(1+1i)
      ## [1] 2+2i

      doubleMeR(c(1+1i, 2+2i))
      ## [1] 2+2i 4+4i





      share|improve this answer












      $endgroup$

















        3














        3










        3







        $begingroup$

        Why choose? C++ is perfectly integrated into R via the excellent Rcpp package (on CRAN). And you can use complex numbers there too:



        library(Rcpp)
        cppFunction("ComplexVector doubleMe(ComplexVector x) return x+x; ")
        doubleMe(1+1i)
        ## [1] 2+2i

        doubleMe(c(1+1i, 2+2i))
        ## [1] 2+2i 4+4i


        I would suggest starting out with R and if you run into performance problems, use C++ via Rcpp.



        Just for reference, the same as above in Base R:



        doubleMeR <- function(x) x+x 
        doubleMeR(1+1i)
        ## [1] 2+2i

        doubleMeR(c(1+1i, 2+2i))
        ## [1] 2+2i 4+4i





        share|improve this answer












        $endgroup$



        Why choose? C++ is perfectly integrated into R via the excellent Rcpp package (on CRAN). And you can use complex numbers there too:



        library(Rcpp)
        cppFunction("ComplexVector doubleMe(ComplexVector x) return x+x; ")
        doubleMe(1+1i)
        ## [1] 2+2i

        doubleMe(c(1+1i, 2+2i))
        ## [1] 2+2i 4+4i


        I would suggest starting out with R and if you run into performance problems, use C++ via Rcpp.



        Just for reference, the same as above in Base R:



        doubleMeR <- function(x) x+x 
        doubleMeR(1+1i)
        ## [1] 2+2i

        doubleMeR(c(1+1i, 2+2i))
        ## [1] 2+2i 4+4i






        share|improve this answer















        share|improve this answer




        share|improve this answer



        share|improve this answer








        edited 5 hours ago

























        answered 7 hours ago









        vonjdvonjd

        20.2k9 gold badges80 silver badges139 bronze badges




        20.2k9 gold badges80 silver badges139 bronze badges
























            ToloponiAdiono is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded

















            ToloponiAdiono is a new contributor. Be nice, and check out our Code of Conduct.












            ToloponiAdiono is a new contributor. Be nice, and check out our Code of Conduct.











            ToloponiAdiono is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Quantitative Finance Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fquant.stackexchange.com%2fquestions%2f49069%2fr-or-cpp-for-some-finance-work-involved-complex-numbers%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480