help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: convert octave Matrix object to std::vector and viceversa


From: nicolas neuman
Subject: Re: convert octave Matrix object to std::vector and viceversa
Date: Fri, 13 Mar 2020 08:32:07 +0100

On Fri, Mar 13, 2020 at 2:58 AM Mike Miller <address@hidden> wrote:
>
> On Thu, Mar 12, 2020 at 16:49:49 -0500, niconeuman wrote:
> > Is there a simple and fast way of casting an octave Matrix of size (N,1) to
> > std::vector inside an Oct-file?
>
> By "casting" do you mean a zero-copy way of sharing the same internal
> buffer? There is no easy way to do that, and seems very unsafe.
>
> If copying is ok, then the simplest way is
>
>     std::copy_n (matrix.data (), matrix.numel (), vector.begin ());
>
> > And the other way around?
>
>     std::copy_n (vector.begin (), vector.size (), matrix.data ());
>
> Hope that helps,
>
> --
> mike

Thank you very much,
I will test it.

-- 
Dr. Nicolas Neuman

Institut für Chemie und Biochemie, Anorganische Chemie
Freie Universität Berlin,
Fabeckstraße 34–36, 14195, Berlin (Germany)

Investigador Adjunto - CIC
Instituto de Desarrollo Tecnológico para la Industria Química - INTEC
UNL-CONICET
CCT-CONICET Santa Fe
S3000ZAA Santa Fe - Santa Fe - Argentina

Jefe de Trabajos Prácticos
Departamento de Física
Fac. de Bioquímica y Ciencias Biológicas
Universidad Nacional del Litoral
Ciudad Universitaria - Paraje El Pozo
S3000ZAA Santa Fe - Santa Fe - Argentina



reply via email to

[Prev in Thread] Current Thread [Next in Thread]