Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8936169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:09:29+00:00 2026-06-15T10:09:29+00:00

I am tying to get around how you will multiply the values in 2

  • 0

I am tying to get around how you will multiply the values in 2 arrays (as an input) to get an output. The problem I have is the how to increment the loops to achieve the task shown below

#include <iostream>

using namespace std;

main()
{
 int* filter1, *signal, fsize1 = 0, fsize2 = 0, i = 0;

 cout << " enter size of filter and signal" << endl;
 cin >> fsize1 >> fsize2;

filter1 = new int [fsize1];
signal = new int [fsize2];

cout << " enter filter  values" << endl;
for (i = 0; i < fsize1; i++)
cin >> filter1[i];
 cout << " enter  signal values" << endl;
for (i = 0; i < fsize2; i++)
cin >> signal[i];

/*

The two arrays should be filled by users but use the arrays below for test:

int array1[6] = {2, 4, 6, 7, 8, 9};
int array2[3] = {1, 2, 3};

The output array should be

array3[8]= {1 * 2, (1 * 4 + 2 * 2), (1 * 6 + 2 * 4 + 3 * 2), (1 * 7 + 2 * 6 + 3 * 4), (1 * 8 + 2 * 7 + 3 * 6), (1 * 9 + 2 * 8 + 3 * 7), (2 * 9 + 3 * 8), 3 * 9}


*/


 return 0;
 }

This is part of a bigger task concerning filter of a sampled signal but it is this multiplication that I cant get done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:09:30+00:00Added an answer on June 15, 2026 at 10:09 am

    I haven’t read a word about convolution in a good 7 years. The following code (which works on your test values) is based entirely on your examples. Since you have not articulated the required algorithm in any formal manner, I cannot be sure that this code will produce the desired output for other inputs.

    I have changed around some of your variable names, and re-ordered some of the code you provided so I could actually think through things.

    #include <iostream>
    using namespace std;
    
    void main ()
    {
        int *signal, *filter, signalLength = 0, filterLength = 0, i = 0;
    
        cout << "Enter size of signal and filter" << endl;
        cin >> signalLength >> filterLength;
    
        signal = new int [signalLength];
        filter = new int [filterLength];
    
        cout << "Enter  signal values" << endl;
        for (i = 0; i < signalLength; i++)
        {
            cin >> signal[i];
        }
    
        cout << "Enter filter  values" << endl;
        for (i = 0; i < filterLength; i++)
        {
            cin >> filter[i];
        }
    
        // It was a stated requirement that the filter array be smaller than
        // the signal array.
        // add a check here and act accordingly
    
        int outputLength = signalLength + filterLength - 1;
        int *output = new int[outputLength];
        int signalLeft = 0;
        int signalRight = 1;
        int filterLeft = 0;
        int filterRight = 1;
        int outputIndex = 0;
        while (signalLeft < signalLength)
        {
            int indexWidth = signalRight - signalLeft;
    
    
            // I sure hope I've interpretted your question correctly.
            // I recommend you read over this loop
            // carefully to ensure it matches your understanding of the problem at hand.
            output[outputIndex] = 0;
            int j = 0;
            while (j < indexWidth)
            {
                output[outputIndex] += signal[signalLeft + j] * 
                                       filter[filterRight - j - 1];
    
                ++j;
            }
    
    
            // The left and right indexes will start the loop 1 index apart
            // The right indexes will increment until the distance between
            //    left and right is equal to the length of the filter array.
            // Then, the signal indexes will increment until the right signal
            //   index is equal to the length of the signal array.
            // Then, both left indexes will increment until the left and right
            //   indexes are again 1 index apart.
            if (filterRight < filterLength)
            {
                ++signalRight;
                ++filterRight;
            }
            else if (signalRight < signalLength)
            {
                ++signalLeft;
                ++signalRight;
            }
            else
            {
                ++signalLeft;
                ++filterLeft;
            }
    
            ++outputIndex;
        }
    
    
        for (i = 0; i < outputLength; ++i)
        {
                cout << i << ": " << output[i] << endl;
        }
    
    
        char dummy;
        cin >> dummy;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to get my head around Feedzirra here. I have it all setup and
I'm trying to get my head around the covariance of Scala's collections. I have
Trying to get my mind around google protobuf. I found some implementation of protobuf
Trying to get my head around how to integrate fancyBox with an aspx c#
Just trying to get my head around what can happen when things go wrong
I'm trying to get my head around using CoffeeScript comprehensions as efficiently as possible.
So I am trying to get a border around buttons on my page when
I am trying to get my head around this query - seems pretty straight
Hi I am trying to get my mind around XSDs, XML and namespaces but
I'm trying to get my head around AMQP . It looks great for inter-machine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.