[Insight-users] [ITK Community] dot product of itk vector was completely wrong

Brian Helba brian.helba at kitware.com
Wed Feb 12 17:20:51 EST 2014


Hi all,

See the patch here: http://review.source.kitware.com/#/c/14418/

Best,
Brian



On Wed, Feb 12, 2014 at 9:48 AM, Bradley Lowekamp <blowekamp at mail.nih.gov>wrote:

> I think this constructor is missing the "explicit" keyword. This may help
> in some situations.
>
> Brad
>
>
> On Feb 12, 2014, at 9:41 AM, Tim Allman <dr.tim.allman at gmail.com> wrote:
>
> > This brings up an issue with respect to design in C++.
> >
> > I have made far too many mistakes like this over the years, usually in
> my own code but with third party libraries as well. This strikes me as a
> constructor that was written as a "convenience" and the compiler happily
> tried to find a way of turning the returned scalar into a vector and made
> no complaints when it did.
> >
> > I would probably not included this constructor at all because the
> following would do the same thing and the code would be clearer and less
> brittle. If it turned out to be useful I would have made it explicit.
> >
> > ...
> > itk::Vector<double, 3> vec;
> > vec.Fill(28.0);
> > ...
> >
> > I think C++ tries to be too friendly and it is too easy to write
> perfectly legal code which doesn't do what you expect.
> >
> > Just a few thoughts,
> > Tim
> >
> > On 14-02-11 07:54 PM, Bradley Lowekamp wrote:
> >> David,
> >>
> >> Thanks for updating the Wiki Examples.
> >>
> >> Brad
> >>
> >> On Feb 11, 2014, at 3:45 PM, David Doria <daviddoria at gmail.com> wrote:
> >>
> >>> On Tue, Feb 11, 2014 at 3:04 PM, Bradley Lowekamp
> >>> <blowekamp at mail.nih.gov> wrote:
> >>>> http://www.itk.org/Doxygen/html/classitk_1_1Vector.html
> >>>>
> >>>> The return type for the operator* for a dot product is
> Vector::ValueType, a
> >>>> scalar, not a vector.
> >>>>
> http://www.itk.org/Doxygen/html/classitk_1_1Vector.html#a51bad5a3835ffc0fbbc02d5437f7e691
> >>>>
> >>>> By assigning to to a new Vector are implicitly calling this
> constructor:
> >>>>
> http://www.itk.org/Doxygen/html/classitk_1_1Vector.html#a106ee9550311054cceb66015e98c6457
> >>>>
> >>>> The example is wrong. Watch your types.
> >>>>
> >>>> Brad
> >>> Brad is right - the 'dotproduct' variable in the example should be a
> >>> VectorType::ComponentType, not just VectorType. I updated the page
> >>> with the fix.
> >>>
> >>> David
> >>> _____________________________________
> >>> Powered by www.kitware.com
> >>>
> >>> Visit other Kitware open-source projects at
> >>> http://www.kitware.com/opensource/opensource.html
> >>>
> >>> Kitware offers ITK Training Courses, for more information visit:
> >>> http://www.kitware.com/products/protraining.php
> >>>
> >>> Please keep messages on-topic and check the ITK FAQ at:
> >>> http://www.itk.org/Wiki/ITK_FAQ
> >>>
> >>> Follow this link to subscribe/unsubscribe:
> >>> http://www.itk.org/mailman/listinfo/insight-users
> >> _____________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Kitware offers ITK Training Courses, for more information visit:
> >> http://www.kitware.com/products/protraining.php
> >>
> >> Please keep messages on-topic and check the ITK FAQ at:
> >> http://www.itk.org/Wiki/ITK_FAQ
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.itk.org/mailman/listinfo/insight-users
> >
> > --
> > Tim Allman, Ph.D.
> > 35 Margaret Street,
> > Guelph Ontario N1E 5R6
> > Canada
> >
> > <dr_tim_allman.vcf>_____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.php
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>



-- 
Brian Helba
Medical Imaging
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140212/77d90d69/attachment.html>


More information about the Insight-users mailing list