MECH 215 Study Guide - Final Guide: Row And Column Vectors, Dot Product

226 views1 pages

Document Summary

Write a function dot_product(file1,file2,file3) which calculates the dot product of two 1d arrays stored in two different files with the file names given by the string variables file1 and file2. Return the result from the function and also save the result into a file with the file name stored in the string variable file3. The function should print out an error message (and not save the result) if the files contain different numbers of elements (i. e. the arrays are not the same size) or the input files cannot be opened. Consider a 2d array a with n rows and m columns where n and m are constant integers defined at the beginning of the program. Develop a program that: checks if n and m are positive values.