缩放矢量 [英] Scale a vector

查看:63
本文介绍了缩放矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我必须将大小为N的数字向量缩放到大小为M的向量。

这种转换就像一个放大图像,但我需要一个矢量。


第二个尺寸可以是M> = N或M <= N,M 0.


每个元素的值可以是0到255.


我可以使用一些方法吗?


我不需要只调整大小。


Thx! ;-)

Matteo Migliore。

Hi!

I''ve to scale a vector of numbers of size N to a vector of size M.
The trasformation is like a zoom on images but I need on a vector.

The second size can be M >= N or M <= N, M 0.

The value for each element can be from 0 to 255.

Is there some methods that can I use?

I don''t need only a resize.

Thx! ;-)
Matteo Migliore.

推荐答案

Matteo Migliore写道:
Matteo Migliore wrote:

嗨!


我必须将大小为N的数字向量缩放到大小为M的向量。

转换是像放大图像,但我需要一个矢量。
Hi!

I''ve to scale a vector of numbers of size N to a vector of size M.
The trasformation is like a zoom on images but I need on a vector.



我不清楚你的描述的确切含义;是N

和M。向量的大小?你是否已经知道这些价值,

还是他们需要计算吗?

向量有多少维度?


无论如何,在我看来,如果你只是进行缩放,它将是

最简单的方法就是编写一个简单的方法来完成工作。


但是,有一个Matrix类;如果你已经知道M和N,并且你的

向量是一个二维向量,你可以初始化一个Matrix实例

,其缩放因子为M / N.对角然后使用

Matrix.TransformVectors()方法来缩放你的向量。


如果上面没有帮助,也许你可以更多具体的。


Pete

I''m not really clear on the exact meaning of your description; is "N"
and "M" the magnitude of the vector? Do you already know those values,
or do they need to be calculated as well? How many dimensions does the
vector have?

Anyway, it seems to me that if you''re just doing scaling, it would be
easiest to just write a simple method that does the work.

However, there is a Matrix class; if you already know M and N, and your
vector is a 2-dimensional vector, you could initialize a Matrix instance
with the scaling factor of M/N along the diagonal and then use the
Matrix.TransformVectors() method to scale your vector.

If the above doesn''t help, maybe you could be more specific.

Pete


Peter Duniho写道:
Peter Duniho wrote:

Matteo Migliore写道:
Matteo Migliore wrote:

>嗨!

我必须将大小为N的数字向量缩放到大小向量M.
这种转变就像放大图像,但我需要一个矢量。
>Hi!

I''ve to scale a vector of numbers of size N to a vector of size M.
The trasformation is like a zoom on images but I need on a vector.



我不清楚你的描述的确切含义;是N

和M。向量的大小?你是否已经知道那些

值,还是需要计算它们?向量有多少

维度?


I''m not really clear on the exact meaning of your description; is "N"
and "M" the magnitude of the vector? Do you already know those
values, or do they need to be calculated as well? How many
dimensions does the vector have?



N是向量的大小,M是处理

的新向量后所需的大小。


使用vector我想要一个int数组:int [] vector = new int [] {10,15,17,

30,200};


在这种情况下N = 5,例如我需要一个大小为8的新向量

重新分配

值。认为这是一条线:

P1(1,10) - P2(2,15) - P3(3,17) - P4(4,30) - P5(5,200)


我需要换行:

P1(1,?) - P2(2,?) - P3(3,?) - P4(4,? ) - P5(5,?) - P6(6,?) - P7(7,?) -

P8(8,?)


或4个元素的新向量,或者等等...

N is the size of the vector, M is the wanted size after the processing
of the new vector.

With vector I intend an array of int: int[] vector = new int[] { 10, 15, 17,
30, 200 };

In this case N = 5 and for example I need a new vector of size 8 that
redistributes
the values. Think that is a line:
P1(1, 10) - P2(2, 15) - P3(3, 17) - P4(4, 30) - P5(5, 200)

I need a new line:
P1(1, ?) - P2(2, ?) - P3(3, ?) - P4(4, ?) - P5(5, ?) - P6(6, ?) - P7(7, ?) -
P8(8, ?)

Or a new vector of 4 elements, or 3 etc...


无论如何,在我看来,如果你只是进行缩放,它将是

最简单的方法是编写一个简单的方法来完成工作。


但是,有一个Matrix类;如果你已经知道M和N,并且

你的向量是一个二维向量,你可以初始化一个Matrix

实例,其缩放因子为M / N.对角线然后

使用Matrix.TransformVectors()方法来缩放矢量。
Anyway, it seems to me that if you''re just doing scaling, it would be
easiest to just write a simple method that does the work.

However, there is a Matrix class; if you already know M and N, and
your vector is a 2-dimensional vector, you could initialize a Matrix
instance with the scaling factor of M/N along the diagonal and then
use the Matrix.TransformVectors() method to scale your vector.



不,它不是一个二维向量,它是一维向量。但是我可以使用Matrix.TransformVectors()获得

No, it''s not a 2-dimensional vector, it''s a 1-dimension vector. But can I
use Matrix.TransformVectors() .


如果上面没有帮助,也许你可以更具体一些。


Pete
If the above doesn''t help, maybe you could be more specific.

Pete



很多! ;-)

Matteo Migliore。

Thx a lot! ;-)
Matteo Migliore.


Matteo Migliore写道:
Matteo Migliore wrote:

N是向量的大小,M是处理

的新向量后的所需大小。
N is the size of the vector, M is the wanted size after the processing
of the new vector.



恕我直言,我们的术语有些问题。例如:

IMHO, we are having some problems with your terminology. For example:


使用向量我打算使用int:int [] vector = new int [] {10,15,

17,30,200};


在这种情况下N = 5,例如我需要一个大小为8的新向量

重新分配值。
With vector I intend an array of int: int[] vector = new int[] { 10, 15,
17, 30, 200 };

In this case N = 5 and for example I need a new vector of size 8 that
redistributes the values.



根据上述声明,M和N是你的

向量的_dimensions_。假设你想继续调用两个数组向量,当然是


Based on the above statement, M and N are the _dimensions_ of your
vectors. Assuming you want to continue calling the two arrays vectors,
of course.


认为这是一行:

P1(1,10) - P2(2,15) - P3(3,17) - P4(4,30) - P5(5,200)
Think that is a line:
P1(1, 10) - P2(2, 15) - P3(3, 17) - P4(4, 30) - P5(5, 200)



那不是一条线。这是一堆线,近似曲线。

That''s not a line. It''s a bunch of lines, approximating a curve.


我需要换行:

P1(1,?) - P2 (2,?) - P3(3,?) - P4(4,?) - P5(5,?) - P6(6,?) - P7(7,

?) - P8 (8,?)
I need a new line:
P1(1, ?) - P2(2, ?) - P3(3, ?) - P4(4, ?) - P5(5, ?) - P6(6, ?) - P7(7,
?) - P8(8, ?)



如果你正在处理向量作为
a二维空间中的第二个坐标的集合(这是上面所暗示的),你为什么不调整输出序列中的第一个坐标?



例如,如果你的原始行是从(1,10)开始到结束于(5,

200)你不也想要得到的行行。也从(1,

10)开始,到(5,200)结束?


就具体的例子而言,那些是什么? ;?"被替换

与?您是否在输入和输出之间有特定的关系

数据?或者是您的问题的一部分,旨在征求意见

关于适当的关系是什么?

If you''re treating the "vector" as a collection of second coordinates in
a 2-dimensional space (which is what the above implies), why are you not
adjusting the first coordinate in the output sequence as well?

For example, if your original "line" starts at (1, 10) and ends at (5,
200) wouldn''t you also want the resulting "line" to also start at (1,
10) and end at (5, 200)?

As far as the specific example goes, what would those "?" be replaced
with? Do you have a specific relationship between the input and output
data in mind? Or is part of your question intended to solicit opinions
regarding what an appropriate relationship would be?


[...]

不,它不是一个二维向量,它是一维向量。但是可以

我使用Matrix.TransformVectors()。
[...]
No, it''s not a 2-dimensional vector, it''s a 1-dimension vector. But can
I use Matrix.TransformVectors() .



我不能使用TransformVectors(),我确定。


至于数据是什么,它在我看来,它不是一个二维的

矢量,也不是一维矢量。数据是1维

数组,_possibly_可以被视为M维向量,但实际上它并不是真的在我看来你的数据确实是一个载体

毕竟。


具体如何缩放输入数据创建所需的

输出数据,恐怕我还没有看到足够的信息来解释

预期的结果是什么。似乎如果你能提供输入和输出的最不好的一个具体例子,那么

将大大有助于更好地解释问题。 br />

Pete

You cannot use TransformVectors(), of that much I am sure.

As for what the data is, it appears to me that it''s not a 2-dimensional
vector, nor is it a 1-dimensional vector. The data is a 1-dimensional
array, which _possibly_ could be treated as an M-dimensional vector but
in fact it doesn''t really appear to me that your data really is a vector
after all.

As for specifically how to "scale" the input data to create the desired
output data, I''m afraid I still don''t see enough information to explain
what the intended results are. It seems that if you could provide at
least one concrete example of both the input and the output, that would
go a long way toward helping explain the problem better.

Pete


这篇关于缩放矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆