Coder Social home page Coder Social logo

Comments (4)

oleksii-nikolaienko avatar oleksii-nikolaienko commented on May 24, 2024 1

Yes, thanks again

from rcpp.

eddelbuettel avatar eddelbuettel commented on May 24, 2024

It's been a while but I have a faint recollection that this may be due char and int8_t clashing 'as they are both the same' and we weren't explicit about about preferring int8_t (which of course does not exist in R). And I guess we need to do what we do for char to that character variables work.

You can always write yourself a custom converter helper for this where the autoMAGIC dispatch fromt the compiler does not work. What you get from R will always be a int32_t so for example in one package where Rcpp is used this happens (and vec is the incoming variable from R

  } else if (dtype == "INT8") {
    IntegerVector v(vec);
    auto n = v.length();
    std::vector<int8_t> x(n);
    for (auto i=0; i<n; i++) {
      x[i] = static_cast<int8_t>(v[i]);
    }

I don't think there is much else you can do. If it bugs you greatly that the compiler complains, see if you can improve it without side effects to char and others. We would be interested ... but as int8_t is somewhat rare in R application this was never a priority.

(Going via interfaces that do know int8_t such as arrow might be an alternative too.)

from rcpp.

oleksii-nikolaienko avatar oleksii-nikolaienko commented on May 24, 2024

Thanks for the explanation. I don't think I can improve as, that's beyond my expertise. So, I guess, I'll resort to static_cast as in your example.

FYI, I need this to write array tags to BAM files given the data from R, and these arrays can be of different type

from rcpp.

eddelbuettel avatar eddelbuettel commented on May 24, 2024

Yep, I know. My day job is at TileDB and the lines I quoted were from our R package which may of course encounter different int sizes and signedness. Ditto with the single cell projects, VCF etc.

I think a one-off helper is fair workaround. Especially as template metaprogramming is hairy.

Ok to close this?

from rcpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.