# Finding max index in a vector

**URL:** <https://www.ruby-forum.com/t/finding-max-index-in-a-vector/240674>\
**Category:** GNU Radio\
**Created:** [April 25, 2014, 4:46am UTC](https://www.ruby-forum.com/t/finding-max-index-in-a-vector/240674 "2014-04-25T04:46:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [April 25, 2014, 4:46am UTC](https://www.ruby-forum.com/t/finding-max-index-in-a-vector/240674/1 "2014-04-25T04:46:19Z")

</div>

How do I find the index of the max value in a vector from GRC?  
The max\_xx block outputs the max value, but not its  
index, despite what it’s documentation says:

“Data is passed in as a vector of length from multiple input sources.  
It will look through these streams of data items and output two  
streams. Stream 0 will contain the index value in the vector where the  
maximum value occurred.”

I checked the code template for max (GR v3.7.3), and it doesn’t even  
seem to retain the index of the max it reports.

@(^.^)@ Ed

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [April 25, 2014, 6:16pm UTC](https://www.ruby-forum.com/t/finding-max-index-in-a-vector/240674/2 "2014-04-25T18:16:19Z")

</div>

On Thu, Apr 24, 2014 at 11:32 AM, Ed Criscuolo  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I checked the code template for max (GR v3.7.3), and it doesn’t even  
> seem to retain the index of the max it reports.
> 
> @(^.^)@ Ed

Ed,

Yeah, this block does not match the description. It simply outputs the  
maximum value for a given vector of samples. I’m going to fix this now  
since I’m about to push a few other changes.

I can see a use for having the block have an optional secondary stream  
with  
the index value, though.

Tom

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [April 25, 2014, 6:16pm UTC](https://www.ruby-forum.com/t/finding-max-index-in-a-vector/240674/3 "2014-04-25T18:16:55Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi Ed,  
I’m on a train. I wanted to try out how long it takes to do it  
including implementing rudimentary QA. So I just went ahead and tried:  
about 205s, most spent on figuring out how to get the IO signature  
straight.  
Enjoy: [Max index filter block · GitHub](https://gist.github.com/marcusmueller/11294819)

Greetings,  
Marcus

On 24.04.2014 17:32, Ed Criscuolo wrote:

> I checked the code template for max (GR v3.7.3), and it doesn’t  
> even seem to retain the index of the max it reports.
> 
> @(^.^)@ Ed
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)  
> -----BEGIN PGP SIGNATURE-----  
> Version: GnuPG v1  
> Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJTWon3AAoJEBQ6EdjyzlHtPcYH/jPOuxdSWizdAEUNK2fipCSp  
0B7M7kKcx7QDNTma27uK80NUQzpIEd7H5QZi1ZUu4xl4/QasDnhjaDSJvnjSxzrb  
LQfBdQZPQs6ce7rtGVMG/i+d8iz/Y0coXRexrOFUTKbS1eECJpUTPlKklRQKM98n  
F6uoF4XBidb0sSPbxQXbCge5Fb7FDOp9MF182vRaRC08dzuxViQW7XMWl8H5D6zT  
UYoqrin2OzhhUpqG5c2Qm4wyb+ow+I/0aX2E29V0Wv0ge5hI3thWvHiOStdej5a8  
3JZygHgJdzlvz/6Pzr2WTnsydZ3AbN5eGWgusNj/3CUgwlQ7r2dy2ccLyKEZqRQ=  
=dI/U  
-----END PGP SIGNATURE-----
