Code Monkey home page Code Monkey logo

Comments (5)

adeguet1 avatar adeguet1 commented on July 29, 2024

I started implementing this on fixed size vectors in branch feature-vector-ref. Syntax is v.Ref<__size>(startPosition). See examples of use in:
https://github.com/jhu-cisst/cisst/blob/feature-vector-ref/cisstVector/examples/tutorial/ExampleReferences.h

Output looks like:

AsColMatrix:
     0.00000
     1.00000
     2.00000
     3.00000
AsRowMatrix:
     0.00000      1.00000      2.00000      3.00000
Ref<2>(1):
     1.00000      2.00000
Ref<2>(3) on a vector of 4 elements will throw an out of range exception
Exception received: vctFixedSizeVectorRef SetRef out of range
v4, last 2 elements replaced:
     0.00000      1.00000      5.50000      5.50000
v4, first 2 elements replaced:
    -1.00000     -1.00000      5.50000      5.50000

All input is welcome. I plan to implement a similar method on dynamic vectors, syntax will be: v.Ref(size, startPosition).

I'll check if we can assign between fixed size and dynamic Ref too so one could do: vFixed4.Ref<2>(0) = vDynamic.Ref(2, 10); // assuming vDynamic.size() large enough.

from cisst.

marcinbalicki avatar marcinbalicki commented on July 29, 2024

Looks great. Should the dynamic version also use the same template syntax? Is it possible to have the same syntax for both?

from cisst.

adeguet1 avatar adeguet1 commented on July 29, 2024

Take a look at example file (link above) for features added for dynamic vectors and assigning back and forth between fixed and dynamic Ref (ed42aa5). Also found by accident the already existing & operator, quite cool, see line 65 in example!

from cisst.

marcinbalicki avatar marcinbalicki commented on July 29, 2024

Looks great.

I recommend to use this example (no ambiguity):
vA.Ref(4) = vB.Ref(6, 4); // assign last 4 vB to first 4 elements of vA

instead of :
vA.Ref(5) = vB.Ref(5, 5); // assign second half of vB to first 5 elements
of vA

Marcin

On Fri, Jan 30, 2015 at 6:20 PM, Anton Deguet [email protected]
wrote:

Take a look at example file (link above) for features added for dynamic
vectors and assigning back and forth between fixed and dynamic Ref (
ed42aa5
ed42aa5).
Also found by accident the already existing & operator, quite cool, see
line 65 in example!


Reply to this email directly or view it on GitHub
#17 (comment).

from cisst.

adeguet1 avatar adeguet1 commented on July 29, 2024

Added code and example for Ref() on fixed size and dynamic matrices (see 22b2201).

from cisst.

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.