Re: [Rd] ALLOCATE in a FORTRAN subroutine
Hi Martyn, Many thanks for your answer. If I make it short : we can, once we know how to do it, 'drive' R from within FORTRAN for example to do a Myarray = seq(0, mydimension) in R once we have compute mydimension in FORTRAN. Is that correct ? If yes : it's too 'complicated' for the time I am hired (I mean I have been hired to do FORTRAN code not to learn R !). Second question : for what I have understood in r_exts, it's more 'efficient' to translate R routines in C rather than in FORTRAN (speed must be the 'same', but there are a lot more possibilities in C for the programmer) : right ? I do not know why my customer (client ?) wanted to translate some R routines in FORTRAN. May be it's by accident (in my humble opinion they even don't know about C). If you confirm this fact, I'll speak about C with my customer because we are at the very beginning of great works (great amounts of work ?) and I don't matter, I am also a skilled C programmer !! I hope you understand what I want to say, english is not my natural language ! Thanks again and best regards. Jean Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme à sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de votre système, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions également d'en avertir immédiatement l'expéditeur par retour du message. Il est impossible de garantir que les communications par messagerie électronique arrivent en temps utile, sont sécurisées ou dénuées de toute erreur ou virus. This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] body(NULL) <- something; ditto formals() -- should not work
I'm proposing to signal an error (from R >= 3.3.0) in such examples -- which do "work" in R 3.2.x and earlier : > f <- NULL; body(f) <- quote(sin(a+1)); f function () sin(a + 1) > g <- NULL; formals(g) <- alist(x = pi, y=); g function (x = pi, y) NULL > The proposal is that the underlying C code will signal an error when such replacement functions would create a function out of "something not a function". Martin Maechler, ETH Zurich __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ALLOCATE in a FORTRAN subroutine
Hi, "we can, once we know how to do it, 'drive' R from within FORTRAN" I am not sure I understand what you mean by this ... You can call routines written in Fortran or C from within R - how easy this is depends on the interfaces to those routines. You can call (some) R functionality from C (see for example http://quantitative-ecology.blogspot.co.uk/2008/11/call-c-from-r-and-r-from-c.html). As you can call C from within Fortran, it is obviously possible also call R from within Fortran, but it is not something I have done so have no idea how much work is required to do that. "for what I have understood in r_exts, it's more 'efficient' to translate R routines in C rather than in FORTRAN" As far as I aware the R API for writing extensions etc is only available in C and there isn't a Fortran equivalent, so I guess it would be more "efficient" / easier in that sense as that would be one less level of cross-language programming you would have to worry about. "I do not know why my customer (client ?) wanted to translate some R routines in FORTRAN." Which language is preferred really boils down to personal preference and I am going to be slightly biased as I do almost all my numerical computing in Fortran. There is a good argument that Fortran is the most natural fit for numerical computing with its built in syntax to deal with complex numbers, matrices, array slicing, array operations etc. In theory this gives compilers a good base to optimise from. The more restrictive nature of Fortran does make it more difficult to interface with other languages than C (but conversely makes it much more difficult to shoot yourself in the foot - and the Fortran compilers tend to pick up more problems at compile time than the C ones). Martyn -Original Message- From: MAURICE Jean - externe [mailto:jean-externe.maur...@edf.fr] Sent: 07 March 2016 15:46 To: Martyn Byng Cc: r-devel@r-project.org Subject: RE: ALLOCATE in a FORTRAN subroutine Hi Martyn, Many thanks for your answer. If I make it short : we can, once we know how to do it, 'drive' R from within FORTRAN for example to do a Myarray = seq(0, mydimension) in R once we have compute mydimension in FORTRAN. Is that correct ? If yes : it's too 'complicated' for the time I am hired (I mean I have been hired to do FORTRAN code not to learn R !). Second question : for what I have understood in r_exts, it's more 'efficient' to translate R routines in C rather than in FORTRAN (speed must be the 'same', but there are a lot more possibilities in C for the programmer) : right ? I do not know why my customer (client ?) wanted to translate some R routines in FORTRAN. May be it's by accident (in my humble opinion they even don't know about C). If you confirm this fact, I'll speak about C with my customer because we are at the very beginning of great works (great amounts of work ?) and I don't matter, I am also a skilled C programmer !! I hope you understand what I want to say, english is not my natural language ! Thanks again and best regards. Jean This e-mail has been scanned for all viruses by Star.\ _...{{dropped:16}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ALLOCATE in a FORTRAN subroutine
> On 7 Mar 2016, at 16:45, MAURICE Jean - externe > wrote: > > Hi Martyn, > > Many thanks for your answer. If I make it short : > we can, once we know how to do it, 'drive' R from within FORTRAN for example > to do a > Myarray = seq(0, mydimension) > in R once we have compute mydimension in FORTRAN. Is that correct ? I too do not understand what you mean by this. I told you on the R-help mailing list that what you could do is to - write a subroutine that calculates the required dimension given your parameters; you can do this within R code. - allocate in R (or C) a matrix/vector/.. with the required dimension. - call your Fortran subroutine(s) with the allocated matrix/vector There are several packages, as I replied before on the R help list, that do this (from within an R function or a C function). Berend > If yes : it's too 'complicated' for the time I am hired (I mean I have been > hired to do FORTRAN code not to learn R !). > > Second question : for what I have understood in r_exts, it's more 'efficient' > to translate R routines in C rather than in FORTRAN (speed must be the > 'same', but there are a lot more possibilities in C for the programmer) : > right ? I do not know why my customer (client ?) wanted to translate some R > routines in FORTRAN. May be it's by accident (in my humble opinion they even > don't know about C). If you confirm this fact, I'll speak about C with my > customer because we are at the very beginning of great works (great amounts > of work ?) and I don't matter, I am also a skilled C programmer !! > > I hope you understand what I want to say, english is not my natural language ! > > Thanks again and best regards. > Jean > > > > Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis > à l'intention exclusive des destinataires et les informations qui y figurent > sont strictement confidentielles. Toute utilisation de ce Message non > conforme à sa destination, toute diffusion ou toute publication totale ou > partielle, est interdite sauf autorisation expresse. > > Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le > copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. > Si vous avez reçu ce Message par erreur, merci de le supprimer de votre > système, ainsi que toutes ses copies, et de n'en garder aucune trace sur > quelque support que ce soit. Nous vous remercions également d'en avertir > immédiatement l'expéditeur par retour du message. > > Il est impossible de garantir que les communications par messagerie > électronique arrivent en temps utile, sont sécurisées ou dénuées de toute > erreur ou virus. > > > This message and any attachments (the 'Message') are intended solely for the > addressees. The information contained in this Message is confidential. Any > use of information contained in this Message not in accord with its purpose, > any dissemination or disclosure, either whole or partial, is prohibited > except formal approval. > > If you are not the addressee, you may not copy, forward, disclose or use any > part of it. If you have received this message in error, please delete it and > all copies from your system and notify the sender immediately by return > message. > > E-mail communication cannot be guaranteed to be timely secure, error or > virus-free. > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ALLOCATE in a FORTRAN subroutine
> On 7 Mar 2016, at 18:55, Berend Hasselman wrote: > >> >> On 7 Mar 2016, at 16:45, MAURICE Jean - externe >> wrote: >> >> Hi Martyn, >> >> Many thanks for your answer. If I make it short : >> we can, once we know how to do it, 'drive' R from within FORTRAN for example >> to do a >> Myarray = seq(0, mydimension) >> in R once we have compute mydimension in FORTRAN. Is that correct ? > > I too do not understand what you mean by this. > > I told you on the R-help mailing list that what you could do is to > > - write a subroutine that calculates the required dimension given your > parameters; you can do this within R code. Correction: write a subroutine in Fortran that calculates the required dimension(s), call that routine from within R and make it return the required dimension(s). etc.etc. Berend > - allocate in R (or C) a matrix/vector/.. with the required dimension. > - call your Fortran subroutine(s) with the allocated matrix/vector > > There are several packages, as I replied before on the R help list, that do > this (from within an R function or a C function). > > > Berend > >> If yes : it's too 'complicated' for the time I am hired (I mean I have been >> hired to do FORTRAN code not to learn R !). >> >> Second question : for what I have understood in r_exts, it's more >> 'efficient' to translate R routines in C rather than in FORTRAN (speed must >> be the 'same', but there are a lot more possibilities in C for the >> programmer) : right ? I do not know why my customer (client ?) wanted to >> translate some R routines in FORTRAN. May be it's by accident (in my humble >> opinion they even don't know about C). If you confirm this fact, I'll speak >> about C with my customer because we are at the very beginning of great works >> (great amounts of work ?) and I don't matter, I am also a skilled C >> programmer !! >> >> I hope you understand what I want to say, english is not my natural language >> ! >> >> Thanks again and best regards. >> Jean >> >> >> >> Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis >> à l'intention exclusive des destinataires et les informations qui y figurent >> sont strictement confidentielles. Toute utilisation de ce Message non >> conforme à sa destination, toute diffusion ou toute publication totale ou >> partielle, est interdite sauf autorisation expresse. >> >> Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le >> copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. >> Si vous avez reçu ce Message par erreur, merci de le supprimer de votre >> système, ainsi que toutes ses copies, et de n'en garder aucune trace sur >> quelque support que ce soit. Nous vous remercions également d'en avertir >> immédiatement l'expéditeur par retour du message. >> >> Il est impossible de garantir que les communications par messagerie >> électronique arrivent en temps utile, sont sécurisées ou dénuées de toute >> erreur ou virus. >> >> >> This message and any attachments (the 'Message') are intended solely for the >> addressees. The information contained in this Message is confidential. Any >> use of information contained in this Message not in accord with its purpose, >> any dissemination or disclosure, either whole or partial, is prohibited >> except formal approval. >> >> If you are not the addressee, you may not copy, forward, disclose or use any >> part of it. If you have received this message in error, please delete it and >> all copies from your system and notify the sender immediately by return >> message. >> >> E-mail communication cannot be guaranteed to be timely secure, error or >> virus-free. >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Could unit.list() from grid package be made an exported function?
Hi I think the right solution is to add [<- methods for units. I will take a look at whether I can get that done for the release of R 3.3.0 Paul On 07/03/16 07:34, Wilke, Claus O wrote: Hello, certain manipulations of ggplot2 graphs, in particular aligning them, require the function grid:::unit.list(). See e.g. these posts on stackoverflow: http://stackoverflow.com/questions/34032621/element-replacement-in-grid-unit-vector http://stackoverflow.com/questions/32580946/setting-absolute-size-of-facets-in-ggplot2/32583612#32583612 http://stackoverflow.com/a/35823179/4975218 Since this seems to be a reasonably common issue, would it be possible to export grid:::unit.list(), so it can be used in packages? (Am I sending this to the right audience? It’s not clear to me how to reach the maintainer of the grid package in base R.) Thanks! Claus -- Claus Wilke Professor and Department Chair, Integrative Biology The University of Texas at Austin 2500 Speedway, A4800 Austin, Texas 78712 512 232 2459 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Could unit.list() from grid package be made an exported function?
Hi Subassignment for units has been committed to r-devel. You should now be able to do things like ... x <- unit(1:3, "mm") x[2] <- unit(.5, "npc") (see grid/tests/units.R for more complex examples) This works for me for the three stackoverflow scenarios. Any confirmation that it also works for you would be welcome. Paul On 07/03/16 07:34, Wilke, Claus O wrote: Hello, certain manipulations of ggplot2 graphs, in particular aligning them, require the function grid:::unit.list(). See e.g. these posts on stackoverflow: http://stackoverflow.com/questions/34032621/element-replacement-in-grid-unit-vector http://stackoverflow.com/questions/32580946/setting-absolute-size-of-facets-in-ggplot2/32583612#32583612 http://stackoverflow.com/a/35823179/4975218 Since this seems to be a reasonably common issue, would it be possible to export grid:::unit.list(), so it can be used in packages? (Am I sending this to the right audience? It’s not clear to me how to reach the maintainer of the grid package in base R.) Thanks! Claus -- Claus Wilke Professor and Department Chair, Integrative Biology The University of Texas at Austin 2500 Speedway, A4800 Austin, Texas 78712 512 232 2459 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel