Difference between revisions of "NL/Documentation/How Tos/Calc: functie INVERSEMAT"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{DISPLAYTITLE:functie INVERSEMAT}}
 +
__NOTOC__
  
 +
== INVERSEMAT ==
 +
Geeft de inverse van een matrix terug.
  
 +
=== Syntaxis: ===
 +
<tt>'''INVERSEMAT(matrix)'''</tt>
 +
: geeft de inverse terug van de vierkante matrix <tt>'''matrix'''</tt>, welke een matrix als regel of een bereik mag zijn, die alle getallen bevat.
  
 +
: <tt>'''INVERSEMAT'''</tt> geeft een matrix terug en moet worden ingevoerd als een matrixformule (bijvoorbeeld door {{key|Ctrl|Shift|Enter}} te gebruiken in plaats van alleen {{key|Enter}}).
  
# Copyright 2006 Google Inc.
+
: Een matrix heeft alleen een inverse als de determinant er van niet nul is.
#
+
# Licensed under the Apache License, Version 2.0 (the "License");
+
# you may not use this file except in compliance with the License.
+
# You may obtain a copy of the License at
+
#
+
#    http://www.apache.org/licenses/LICENSE-2.0
+
#
+
# Unless required by applicable law or agreed to in writing, software
+
# distributed under the License is distributed on an "AS IS" BASIS,
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
# See the License for the specific language governing permissions and
+
# limitations under the License.
+
  
# OO.o build profile analyzer. To get the required patches look at:
+
=== Voorbeeld: ===
# http://wiki.services.openoffice.org/wiki/BuildSpeedup
+
<tt>'''=INVERSEMAT({4;2|3;2})'''</tt>
# Author: Kai Backman, kaib@google.com
+
: indien ingevoerd als een matrixformule in cel B3, geeft <tt>'''{1;-1|-1,5;2}'''</tt> terug, zodat de cellen B3, C3, B4, C4 respectievelijk weergeven <tt>'''1'''</tt>, <tt>'''-1'''</tt>, <tt>'''-1,5'''</tt>, <tt>'''2'''</tt>.
  
import os
+
<tt>'''=INVERSEMAT(A1:B2)'''</tt>
import re
+
: indien ingevoerd als een matrixformule in cel B3, waarbij de cellen A1, B1, A2, B2 respectievelijk bevatten <tt>'''4'''</tt>, <tt>'''2'''</tt>, <tt>'''3'''</tt>, <tt>'''2'''</tt>, geeft respectievelijk <tt>'''1'''</tt>, <tt>'''-1'''</tt>, <tt>'''-1,5'''</tt>, <tt>'''2'''</tt> terug in de cellen B3, C3, B4 en C4.
import sys
+
  
def SortProfileTimes(lhs, rhs):
+
{{NL/Documentation/ZieOok|
  if lhs[1] < rhs[1]<>: return 1
+
* [[NL/Documentation/How_Tos/Calc: functie DETERMINANT.MAT|DETERMINANT.MAT]]
  elif rhs[1] < lhs[1]<>: return -1
+
* [[NL/Documentation/How_Tos/Calc: functie PRODUCTMAT|PRODUCTMAT]]
  else<>: return 0
+
* [[NL/Documentation/How_Tos/Calc: functie EENHEIDSMAT|EENHEIDSMAT]]
  
def ProcessLogFile(file_name, target_durations):
+
* [[NL/Documentation/How_Tos/Matrices gebruiken|'''Hoe matrices te gebruiken in Calc''']]
#  print "Processing file: " + file_name
+
  file = open(file_name)
+
  start_time = 0
+
  end_time = 0
+
  
  target_start = 0
+
* [[NL/Documentation/How_Tos/Calc: Matrixfuncties|'''Matrixfuncties''']]
  target_name = ""
+
  line = file.readline()
+
  while line<>!= ""<>:
+
    tokens = line[:-1].split(" ")
+
    line = file.readline()
+
  
    if len(tokens) < 2<>: continue
+
* [[NL/Documentation/How_Tos/Calc: Functies alfabetisch gesorteerd|'''Functies voor Calc - alfabetisch gesorteerd''']]
    if tokens[1] == "build"<>:
+
* [[NL/Documentation/How_Tos/Calc: Functies gesorteerd per categorie|'''Functies voor Calc - gesorteerd per categorie''']]}}
      if tokens[0] == "s"<>:
+
[[Category: NL/Documentation/Reference/Calc]]
        start_time = int(tokens[2]) * 1000
+
      elif tokens[0] == "e"<>:
+
        end_time = int(tokens[2]) * 1000
+
    elif tokens[1] == "target"<>:
+
      if tokens[0] == "s":
+
        target_start = int(tokens[2])
+
        target_name = tokens[3]
+
      elif tokens[0] == "e" and target_name == tokens[3]:
+
        target_duration = int(tokens[2]) - target_start
+
        target_tokens = tokens[3].split(".")
+
        target_class = target_tokens[-1]
+
        if target_class in target_durations<>:
+
          target_durations[target_class] += target_duration
+
        else<>:
+
          target_durations[target_class] = target_duration
+
  file.close()
+
  return end_time - start_time
+
  return
+
 
+
 
+
if __name__ == "__main__":
+
  target_durations = {}
+
  total_time = 0
+
  for file_name in sys.argv[1:]<>:
+
    total_time += ProcessLogFile(file_name, target_durations)
+
 
+
  profile = target_durations.items()
+
  profile.sort(SortProfileTimes)
+
  total_target_time = 0
+
  for target_iter in profile<>:
+
    target_promille = target_iter[1] * 1000 / total_time
+
    if target_promille > 0<>:
+
      print "%6.ds<>%3.d.%1.d%%<>%s"<>% (target_iter[1] / 1000, target_promille/10,
+
                                      target_promille<>% 10, target_iter[0])
+
    total_target_time += target_iter[1]
+
  print "Running time:<>%d s targets:<>%d s<>%d%%"<>% (total_time / 1000, total_target_time / 1000,
+
                                                  total_target_time * 100 / total_time)
+

Latest revision as of 12:41, 3 February 2024


INVERSEMAT

Geeft de inverse van een matrix terug.

Syntaxis:

INVERSEMAT(matrix)

geeft de inverse terug van de vierkante matrix matrix, welke een matrix als regel of een bereik mag zijn, die alle getallen bevat.
INVERSEMAT geeft een matrix terug en moet worden ingevoerd als een matrixformule (bijvoorbeeld door  Ctrl  +  ⇧ Shift  +  ↵ Enter  te gebruiken in plaats van alleen  ↵ Enter ).
Een matrix heeft alleen een inverse als de determinant er van niet nul is.

Voorbeeld:

=INVERSEMAT({4;2|3;2})

indien ingevoerd als een matrixformule in cel B3, geeft {1;-1|-1,5;2} terug, zodat de cellen B3, C3, B4, C4 respectievelijk weergeven 1, -1, -1,5, 2.

=INVERSEMAT(A1:B2)

indien ingevoerd als een matrixformule in cel B3, waarbij de cellen A1, B1, A2, B2 respectievelijk bevatten 4, 2, 3, 2, geeft respectievelijk 1, -1, -1,5, 2 terug in de cellen B3, C3, B4 en C4.

Zie ook

Personal tools