hello, first time poster and accelerate question

Hello everyone,

Nice to meet y'all, and here's my first question:

I am currently setting a semantically easy to use accelerate operation extension set for my research.

I have done all the basic operations, vector to scalar, vector to vector, matrix mult matrix, transpose etc, but would like to know what the best approach might be for getting the mean for a matrix, as I am not sure if the result is what I think it is. In fact, I would like an output of m by 1 from an n by m matrix with means of each column vector.

The function is:
func vDSP_meanvD(UnsafePointer<Double>, vDSP_Stride, UnsafeMutablePointer<Double>, vDSP_Length)

I assume for a vector this is fine since it is 1 dimensional, but for matrices here is my question:

What is the approach to take?
1-Do I slice my matrix into m copies of size n where M_i(n by m) and pass them all through vDSP_meanvD?
2- Does the stride argument take care of this, in that if I have stride of n, then the ranges [0:n], [n+1: 2n], [2n+1: 3n] will have their mean and std computed?

Thanks for any pointer

Best regards,

Can't you achieve this with a single vector*matrix multiplication?

[1/n, 1/n, ..., 1/n] * A = [mean(col 1); mean(col 2); ...; mean(col n)]

Or in more legible form:

<img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/swift/original/1X/7cf4bf0bf7dbb8dcc51516ea22179f44269931f9.png' width='690' height='249'>

Jacob

···

On Fri, Nov 18, 2016 at 5:36 AM, Yuma Decaux via swift-users < swift-users@swift.org> wrote:

Hello everyone,

Nice to meet y'all, and here's my first question:

I am currently setting a semantically easy to use accelerate operation
extension set for my research.

I have done all the basic operations, vector to scalar, vector to vector,
matrix mult matrix, transpose etc, but would like to know what the best
approach might be for getting the mean for a matrix, as I am not sure if
the result is what I think it is. In fact, I would like an output of m by 1
from an n by m matrix with means of each column vector.

The function is:
func vDSP_meanvD(UnsafePointer<Double>, vDSP_Stride,
UnsafeMutablePointer<Double>, vDSP_Length)

I assume for a vector this is fine since it is 1 dimensional, but for
matrices here is my question:

What is the approach to take?
1-Do I slice my matrix into m copies of size n where M_i(n by m) and pass
them all through vDSP_meanvD?
2- Does the stride argument take care of this, in that if I have stride of
n, then the ranges [0:n], [n+1: 2n], [2n+1: 3n] will have their mean and
std computed?

Thanks for any pointer

Best regards,

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

I must have forgotten how matrices work—I think it's actually this
direction. And I also lost an m :-)

<img src='//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/swift/original/1X/5ae83c8d5afee8d0e8a2e47819ff55f5b9855be3.png' width='690' height='92'>

···

On Fri, Nov 18, 2016 at 7:55 PM, Jacob Bandes-Storch <jtbandes@gmail.com> wrote:

Can't you achieve this with a single vector*matrix multiplication?

[1/n, 1/n, ..., 1/n] * A = [mean(col 1); mean(col 2); ...; mean(col
n)]

Or in more legible form:

[image: Inline image 1]

Jacob

On Fri, Nov 18, 2016 at 5:36 AM, Yuma Decaux via swift-users < > swift-users@swift.org> wrote:

Hello everyone,

Nice to meet y'all, and here's my first question:

I am currently setting a semantically easy to use accelerate operation
extension set for my research.

I have done all the basic operations, vector to scalar, vector to vector,
matrix mult matrix, transpose etc, but would like to know what the best
approach might be for getting the mean for a matrix, as I am not sure if
the result is what I think it is. In fact, I would like an output of m by 1
from an n by m matrix with means of each column vector.

The function is:
func vDSP_meanvD(UnsafePointer<Double>, vDSP_Stride,
UnsafeMutablePointer<Double>, vDSP_Length)

I assume for a vector this is fine since it is 1 dimensional, but for
matrices here is my question:

What is the approach to take?
1-Do I slice my matrix into m copies of size n where M_i(n by m) and pass
them all through vDSP_meanvD?
2- Does the stride argument take care of this, in that if I have stride
of n, then the ranges [0:n], [n+1: 2n], [2n+1: 3n] will have their mean and
std computed?

Thanks for any pointer

Best regards,

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

If only you could write this directly in Swift and have it use accelerate…

-Kenny

···

On Nov 18, 2016, at 8:07 PM, Jacob Bandes-Storch via swift-users <swift-users@swift.org> wrote:

I must have forgotten how matrices work—I think it's actually this direction. And I also lost an m :-)

<image.png>

On Fri, Nov 18, 2016 at 7:55 PM, Jacob Bandes-Storch <jtbandes@gmail.com> wrote:
Can't you achieve this with a single vector*matrix multiplication?

[1/n, 1/n, ..., 1/n] * A = [mean(col 1); mean(col 2); ...; mean(col n)]

Or in more legible form:

<image.png>

Jacob

On Fri, Nov 18, 2016 at 5:36 AM, Yuma Decaux via swift-users <swift-users@swift.org> wrote:
Hello everyone,

Nice to meet y'all, and here's my first question:

I am currently setting a semantically easy to use accelerate operation extension set for my research.

I have done all the basic operations, vector to scalar, vector to vector, matrix mult matrix, transpose etc, but would like to know what the best approach might be for getting the mean for a matrix, as I am not sure if the result is what I think it is. In fact, I would like an output of m by 1 from an n by m matrix with means of each column vector.

The function is:
func vDSP_meanvD(UnsafePointer<Double>, vDSP_Stride, UnsafeMutablePointer<Double>, vDSP_Length)

I assume for a vector this is fine since it is 1 dimensional, but for matrices here is my question:

What is the approach to take?
1-Do I slice my matrix into m copies of size n where M_i(n by m) and pass them all through vDSP_meanvD?
2- Does the stride argument take care of this, in that if I have stride of n, then the ranges [0:n], [n+1: 2n], [2n+1: 3n] will have their mean and std computed?

Thanks for any pointer

Best regards,

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Take a look at the Surge library.

···

On Tue., 22 Nov. 2016 at 4:24 am, Kenny Leung via swift-users < swift-users@swift.org> wrote:

If only you could write this directly in Swift and have it use accelerate…

-Kenny

> On Nov 18, 2016, at 8:07 PM, Jacob Bandes-Storch via swift-users < > swift-users@swift.org> wrote:
>
> I must have forgotten how matrices work—I think it's actually this
direction. And I also lost an m :-)
>
> <image.png>
>
>
> On Fri, Nov 18, 2016 at 7:55 PM, Jacob Bandes-Storch <jtbandes@gmail.com> > wrote:
> Can't you achieve this with a single vector*matrix multiplication?
>
> [1/n, 1/n, ..., 1/n] * A = [mean(col 1); mean(col 2); ...; mean(col
n)]
>
> Or in more legible form:
>
> <image.png>
>
> Jacob
>
> On Fri, Nov 18, 2016 at 5:36 AM, Yuma Decaux via swift-users < > swift-users@swift.org> wrote:
> Hello everyone,
>
> Nice to meet y'all, and here's my first question:
>
> I am currently setting a semantically easy to use accelerate operation
extension set for my research.
>
> I have done all the basic operations, vector to scalar, vector to
vector, matrix mult matrix, transpose etc, but would like to know what the
best approach might be for getting the mean for a matrix, as I am not sure
if the result is what I think it is. In fact, I would like an output of m
by 1 from an n by m matrix with means of each column vector.
>
> The function is:
> func vDSP_meanvD(UnsafePointer<Double>, vDSP_Stride,
UnsafeMutablePointer<Double>, vDSP_Length)
>
> I assume for a vector this is fine since it is 1 dimensional, but for
matrices here is my question:
>
> What is the approach to take?
> 1-Do I slice my matrix into m copies of size n where M_i(n by m) and
pass them all through vDSP_meanvD?
> 2- Does the stride argument take care of this, in that if I have stride
of n, then the ranges [0:n], [n+1: 2n], [2n+1: 3n] will have their mean and
std computed?
>
>
> Thanks for any pointer
>
> Best regards,
>
>
>
>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

--
-- Howard.

Looks good!

-Kenny

···

On Nov 21, 2016, at 3:47 PM, Howard Lovatt <howard.lovatt@gmail.com> wrote:

Take a look at the Surge library.

On Tue., 22 Nov. 2016 at 4:24 am, Kenny Leung via swift-users <swift-users@swift.org> wrote:
If only you could write this directly in Swift and have it use accelerate…

-Kenny

> On Nov 18, 2016, at 8:07 PM, Jacob Bandes-Storch via swift-users <swift-users@swift.org> wrote:
>
> I must have forgotten how matrices work—I think it's actually this direction. And I also lost an m :-)
>
> <image.png>
>
>
> On Fri, Nov 18, 2016 at 7:55 PM, Jacob Bandes-Storch <jtbandes@gmail.com> wrote:
> Can't you achieve this with a single vector*matrix multiplication?
>
> [1/n, 1/n, ..., 1/n] * A = [mean(col 1); mean(col 2); ...; mean(col n)]
>
> Or in more legible form:
>
> <image.png>
>
> Jacob
>
> On Fri, Nov 18, 2016 at 5:36 AM, Yuma Decaux via swift-users <swift-users@swift.org> wrote:
> Hello everyone,
>
> Nice to meet y'all, and here's my first question:
>
> I am currently setting a semantically easy to use accelerate operation extension set for my research.
>
> I have done all the basic operations, vector to scalar, vector to vector, matrix mult matrix, transpose etc, but would like to know what the best approach might be for getting the mean for a matrix, as I am not sure if the result is what I think it is. In fact, I would like an output of m by 1 from an n by m matrix with means of each column vector.
>
> The function is:
> func vDSP_meanvD(UnsafePointer<Double>, vDSP_Stride, UnsafeMutablePointer<Double>, vDSP_Length)
>
> I assume for a vector this is fine since it is 1 dimensional, but for matrices here is my question:
>
> What is the approach to take?
> 1-Do I slice my matrix into m copies of size n where M_i(n by m) and pass them all through vDSP_meanvD?
> 2- Does the stride argument take care of this, in that if I have stride of n, then the ranges [0:n], [n+1: 2n], [2n+1: 3n] will have their mean and std computed?
>
>
> Thanks for any pointer
>
> Best regards,
>
>
>
>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
--
-- Howard.