Created
January 19, 2015 17:38
-
-
Save ddworken/5578ff2f1bf19dc114f8 to your computer and use it in GitHub Desktop.
Matrix cosine to the p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import sys | |
import pprint | |
import math | |
inArr = [] | |
matrix = [[0 for x in range(len(sys.argv)-1)] for x in range(len(sys.argv)-1)] | |
p = float(sys.argv[1]) | |
sum = 0 | |
for index,item in enumerate(sys.argv): | |
if index is not 0 and index is not 1: | |
# print item | |
# print int(item) | |
inArr.append(int(item)) | |
#print inArr | |
for index,item in enumerate(inArr): | |
for index2,item2 in enumerate(inArr): | |
matrix[index][index2] = math.cos(item-item2)**p | |
# print str(index) + ": " + str(item-item2) | |
for row in range (len(matrix)): | |
for col in range(len(matrix)): | |
sum += matrix[row][col] | |
print("sum = " + str(sum)) | |
pprint.pprint(matrix) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment