From patchwork Tue Sep 13 18:10:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 4051 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C9AC123EF7 for ; Tue, 13 Sep 2011 18:10:26 +0000 (UTC) Received: from mail-ew0-f51.google.com (mail-ew0-f51.google.com [209.85.215.51]) by fiordland.canonical.com (Postfix) with ESMTP id B3AEDA18306 for ; Tue, 13 Sep 2011 18:10:26 +0000 (UTC) Received: by ewy6 with SMTP id 6so669509ewy.38 for ; Tue, 13 Sep 2011 11:10:26 -0700 (PDT) Received: by 10.223.34.143 with SMTP id l15mr321605fad.46.1315937426402; Tue, 13 Sep 2011 11:10:26 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs18275lab; Tue, 13 Sep 2011 11:10:26 -0700 (PDT) Received: by 10.216.170.72 with SMTP id o50mr1806063wel.103.1315937425810; Tue, 13 Sep 2011 11:10:25 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id k18si2415866wed.16.2011.09.13.11.10.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Sep 2011 11:10:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1R3XRB-0004fG-8j for ; Tue, 13 Sep 2011 18:10:25 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 339B0E003F for ; Tue, 13 Sep 2011 18:10:25 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: libmatrix X-Launchpad-Branch: ~jesse-barker/libmatrix/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 25 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~jesse-barker/libmatrix/trunk] Rev 25: Add component-wise multiplication and division operators for vectors. Add Message-Id: <20110913181025.19264.8681.launchpad@ackee.canonical.com> Date: Tue, 13 Sep 2011 18:10:25 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13921"; Instance="initZopeless config overlay" X-Launchpad-Hash: 5992260858d4651045fb1a21e3e1398afd0aa83a ------------------------------------------------------------ revno: 25 committer: Jesse Barker branch nick: trunk timestamp: Tue 2011-09-13 11:04:53 -0700 message: Add component-wise multiplication and division operators for vectors. Add appropriate cases to the const vector test. modified: test/const_vec_test.cc vec.h --- lp:libmatrix https://code.launchpad.net/~jesse-barker/libmatrix/trunk You are subscribed to branch lp:libmatrix. To unsubscribe from this branch go to https://code.launchpad.net/~jesse-barker/libmatrix/trunk/+edit-subscription === modified file 'test/const_vec_test.cc' --- test/const_vec_test.cc 2011-09-13 16:33:49 +0000 +++ test/const_vec_test.cc 2011-09-13 18:04:53 +0000 @@ -27,6 +27,8 @@ const vec2 b(2.0, 2.0); vec2 aplusb(a + b); vec2 aminusb(a - b); + vec2 atimesb(a * b); + vec2 adivb(a / b); } void @@ -36,6 +38,8 @@ const vec3 b(2.0, 2.0, 2.0); vec3 aplusb(a + b); vec3 aminusb(a - b); + vec3 atimesb(a * b); + vec3 adivb(a / b); } void @@ -45,4 +49,6 @@ const vec4 b(2.0, 2.0, 2.0, 2.0); vec4 aplusb(a + b); vec4 aminusb(a - b); + vec4 atimesb(a * b); + vec4 adivb(a / b); } === modified file 'vec.h' --- vec.h 2011-09-13 16:33:49 +0000 +++ vec.h 2011-09-13 18:04:53 +0000 @@ -1,5 +1,5 @@ // -// Copyright (c) 2010 Linaro Limited +// Copyright (c) 2010-2011 Linaro Limited // // All rights reserved. This program and the accompanying materials // are made available under the terms of the MIT License which accompanies @@ -69,6 +69,18 @@ return tvec2(*this) /= rhs; } + tvec2& operator/=(const tvec2& rhs) + { + x_ /= rhs.x_; + y_ /= rhs.y_; + return *this; + } + + const tvec2 operator/(const tvec2& rhs) const + { + return tvec2(*this) /= rhs; + } + tvec2& operator*=(const T& rhs) { x_ *= rhs; @@ -81,6 +93,18 @@ return tvec2(*this) *= rhs; } + tvec2& operator*=(const tvec2& rhs) + { + x_ *= rhs.x_; + y_ *= rhs.y_; + return *this; + } + + const tvec2 operator*(const tvec2& rhs) const + { + return tvec2(*this) *= rhs; + } + tvec2& operator+=(const T& rhs) { x_ += rhs; @@ -211,6 +235,19 @@ return tvec3(*this) /= rhs; } + tvec3& operator/=(const tvec3& rhs) + { + x_ /= rhs.x_; + y_ /= rhs.y_; + z_ /= rhs.z_; + return *this; + } + + const tvec3 operator/(const tvec3& rhs) const + { + return tvec3(*this) /= rhs; + } + tvec3& operator*=(const T& rhs) { x_ *= rhs; @@ -224,6 +261,19 @@ return tvec3(*this) *= rhs; } + tvec3& operator*=(const tvec3& rhs) + { + x_ *= rhs.x_; + y_ *= rhs.y_; + z_ *= rhs.z_; + return *this; + } + + const tvec3 operator*(const tvec3& rhs) const + { + return tvec3(*this) *= rhs; + } + tvec3& operator+=(const T& rhs) { x_ += rhs; @@ -375,6 +425,20 @@ return tvec4(*this) /= rhs; } + tvec4& operator/=(const tvec4& rhs) + { + x_ /= rhs.x_; + y_ /= rhs.y_; + z_ /= rhs.z_; + w_ /= rhs.w_; + return *this; + } + + const tvec4 operator/(const tvec4& rhs) const + { + return tvec4(*this) /= rhs; + } + tvec4& operator*=(const T& rhs) { x_ *= rhs; @@ -389,6 +453,20 @@ return tvec4(*this) *= rhs; } + tvec4& operator*=(const tvec4& rhs) + { + x_ *= rhs.x_; + y_ *= rhs.y_; + z_ *= rhs.z_; + w_ *= rhs.w_; + return *this; + } + + const tvec4 operator*(const tvec4& rhs) const + { + return tvec4(*this) *= rhs; + } + tvec4& operator+=(const T& rhs) { x_ += rhs;