Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1. Fast Matrix Power The goal of this exercise is to modify the power method as seen in class to support Matrix Multiplication instead

Problem 1. Fast Matrix Power

The goal of this exercise is to modify the power method as seen in class to support Matrix Multiplication instead of integer multiplication. As an input, we are given a double array and a non-negative integer. Using recursive algorithm, given matrix M as matrix[][], and a non-negative integer k, write a method that outputs Mk . That is if k is even;

image text in transcribed

If k is odd;

image text in transcribed

You should write your own matrix multiplication function as a subroutine. No points will be given for non-recursive or inefficient solution.

image text in transcribed

you need to use O( log k ) matrix multiplications

assume m to be square

powers method:

int powers (int a, int k) {

if (k == 0)

return 1;

int square = powers (a, k/2);

if (k%2 == 0)

return square * square;

else return square*square*a;

}

Mk = M*/2 * Mk/2 Mk = Mk/2 * Mk/2 * M (Hint: M = I where I is an n xn identity matrix) Mk = M*/2 * Mk/2 Mk = Mk/2 * Mk/2 * M (Hint: M = I where I is an n xn identity matrix)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago